You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-22 15:06:45 +00:00
Fixed the decimals function, it can't be perfect but it should be good enough. Closes #1955
This commit is contained in:
@@ -207,9 +207,15 @@ double Math::ceil(double p_x) {
|
|||||||
int Math::decimals(double p_step) {
|
int Math::decimals(double p_step) {
|
||||||
|
|
||||||
int max=4;
|
int max=4;
|
||||||
|
double llimit = Math::pow(0.1,max);
|
||||||
|
double ulimit = 1.0-llimit;
|
||||||
int i=0;
|
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;
|
p_step*=10.0;
|
||||||
max--;
|
max--;
|
||||||
i++;
|
i++;
|
||||||
|
|||||||
Reference in New Issue
Block a user