diff options
| author | Juan Linietsky | 2016-01-03 19:18:47 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2016-01-03 19:18:47 -0300 |
| commit | 7a931b4d3acc5571223e9954142f4d9548cf7ead (patch) | |
| tree | 7e78152ea4b8b843276b2d0626fbecf9ff1adc95 /core/math/math_funcs.cpp | |
| parent | 908f75c23fdd285523aeae3631b654f9b49c7b59 (diff) | |
| download | godot-7a931b4d3acc5571223e9954142f4d9548cf7ead.tar.gz godot-7a931b4d3acc5571223e9954142f4d9548cf7ead.tar.zst godot-7a931b4d3acc5571223e9954142f4d9548cf7ead.zip | |
Diffstat (limited to 'core/math/math_funcs.cpp')
| -rw-r--r-- | core/math/math_funcs.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp index 2f0c1a651..20d9db337 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 (d<llimit || d>ulimit) + break; p_step*=10.0; max--; i++; |
