This is probably a very easy answer, but I couldn't figure out what the problem is in this situation. I would like to convert a double to a short (and vice versa), but by doing so I get different results.
For example:
double test = 33768; test=33769
short valuetest = (short)test; valuetest = -31768
short test2 = -31768; test2 = -31768
double valuetest2 = (double) test2; valuetest2 = -31768
In my use case, valuetest2 should have the value 33768, or that's what I try to accomplish anyway. What's the better way to achieve this result? Or could someone explain why by casting the value of the first test changes from 33769 to -31768? Thanks in advance!