diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp index 2f0c1a6512b..20d9db33757 100644 --- a/core/math/math_funcs.cpp +++ b/core/math/math_funcs.cpp @@ -207,9 +207,15 @@ double Math::ceil(double p_x) { int Math::decimals(double p_step) { int max=4; + double llimit = Math::pow(0.1,max); + double ulimit = 1.0-llimit; int i=0; - while( (p_step - Math::floor(p_step)) != 0.0 && max) { - + while( max) { + + float d = absf(p_step) - Math::floor(absf(p_step)); + + if (dulimit) + break; p_step*=10.0; max--; i++;