🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Float division
Hello,
I've got following code:
float factor = 0.5f;
int t = float(timeout) / factor; // timeout is integer value
And it gives me division by zero error. Am I doing something wrong, or is this a bug?
I can't reproduce this error. I tested with both 2.15.2 and the latest WIP.
Can you send me a test that reproduces the bug?
Can you send me a test that reproduces the bug?
Hello,
Version 2.16.0, and still the same:
float t = 1.0f / 0.5f;
Gives compile-time division by zero... It just looks like float literals are casted to integers during compilation...
[Edited by - scypior on April 4, 2009 5:44:10 PM]
Version 2.16.0, and still the same:
float t = 1.0f / 0.5f;
Gives compile-time division by zero... It just looks like float literals are casted to integers during compilation...
[Edited by - scypior on April 4, 2009 5:44:10 PM]
This may have to do with your locale settings. Is your OS configured to use comma as the floating point decimal character?
I'll make some tests on this.
I'll make some tests on this.
Ah, at least we have confirmed the cause.
Obviously the compiler cannot be affected by this locale, so I'll have to find a way to turn off international settings while compiling (or perhaps write my own string to float converter).
Obviously the compiler cannot be affected by this locale, so I'll have to find a way to turn off international settings while compiling (or perhaps write my own string to float converter).
Try adding:
to your program somewhere before you create the script engine. Does that help?
setlocale(LC_ALL, "C");
to your program somewhere before you create the script engine. Does that help?
I just checked in a fix for this. I simply added a call to setlocale(LC_NUMERIC,"C") before calling strtod in the compiler. Afterwards I restore the original local so the rest of the application isn't affected.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement