Hello. I've come across a rather interesting problem involving float to int conversions. If I have a float, say, 98.85, and I assign an int to this float times 100...
myint becomes 9884, which is not what I want. Is there anyway to do this float->int conversion without losing precision and without making myint a float? I've figured a rather hack-like workaround by simply adding one to myint, but I would much rather a solution which did not involve this step.
Thanks.
Code Select
float myfloat = 98.85;
int myint = myfloat * 100;
myint becomes 9884, which is not what I want. Is there anyway to do this float->int conversion without losing precision and without making myint a float? I've figured a rather hack-like workaround by simply adding one to myint, but I would much rather a solution which did not involve this step.
Thanks.