Game Development Community

Potential modulus bug

by Daniel Buckmaster · in Torque 3D Beginner · 07/03/2013 (4:52 am) · 1 replies

Does anyone want to verify this? I've been trying to use modulo arithmetic for a GUI operation where I need to round values to the nearest 0.1. Basically I do mFmod(value, 0.1) and then check whether it's 0 or not. But have a look at this:
==>mFmod(0.3, 0.1);
0
==>mFmod(0.4, 0.1);
0
==>mFmod(0.5, 0.1);
0.1
==>mFmod(0.6, 0.1);
1.49012e-008
The 0.6 is fine, that's just floating-point error. But what is going on with 0.5? Pretty sure that's not right. But the call to mFmod is doing nothing more than wrapping the C++ math functions. Spooky.

About the author

Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!


#1
07/03/2013 (9:24 am)
Strings and floats, strings and floats....

Got to be in the string conversion somewhere.