Original Post
Hello all,
I''m having a weird bug that I think is because of converting var types but I cant seem to catch it in the debugger. Let me show you the code.
double insert = currOC * 100.0;
insert += 0.01;
int woah = insert;
-currOC can be anything from 0.01 -> 0.24
-the line with insert += 0.01 fixes the problem is a hack that works but I would sill like to know whats going on.
when currOC is 0.15 -> 0.24 my woah var becomes 15 -> 24
for 0.11 -> 0.14 woah becomes 10 -> 13 (it rounds down)
then from 0.03 -> 0.10 it works correctly
0.01 -> 0.02 it rounds down again.
This seems weird to me because the value of insert always equals a whole number like 15.000000000, or 9.00000000000 so I dont see where the rounding down is comming from? Could it be because 14.00000000000 is really 13.99999999999999 or something? Because that hack of adding .01 to the value fixes everything.
Please help if you can.
Thanks,
nextgengamer