mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-03 22:51:06 +01:00 
			
		
		
		
	RoundScalar() fallback use powf(10.f, -x) instead of 1.0f/powf(10.0f,x)
This commit is contained in:
		@@ -6000,7 +6000,7 @@ static inline float RoundScalar(float value, int decimal_precision)
 | 
				
			|||||||
    // So when our value is 1.99999 with a precision of 0.001 we'll end up rounding to 2.0
 | 
					    // So when our value is 1.99999 with a precision of 0.001 we'll end up rounding to 2.0
 | 
				
			||||||
    // FIXME: Investigate better rounding methods
 | 
					    // FIXME: Investigate better rounding methods
 | 
				
			||||||
    static const float min_steps[10] = { 1.0f, 0.1f, 0.01f, 0.001f, 0.0001f, 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, 0.000000001f }; 
 | 
					    static const float min_steps[10] = { 1.0f, 0.1f, 0.01f, 0.001f, 0.0001f, 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, 0.000000001f }; 
 | 
				
			||||||
    float min_step = (decimal_precision >= 0 && decimal_precision < 10) ? min_steps[decimal_precision] : (1.0f / powf(10.0f, (float)decimal_precision));
 | 
					    float min_step = (decimal_precision >= 0 && decimal_precision < 10) ? min_steps[decimal_precision] : powf(10.0f, (float)-decimal_precision);
 | 
				
			||||||
    bool negative = value < 0.0f;
 | 
					    bool negative = value < 0.0f;
 | 
				
			||||||
    value = fabsf(value);
 | 
					    value = fabsf(value);
 | 
				
			||||||
    float remainder = fmodf(value, min_step);
 | 
					    float remainder = fmodf(value, min_step);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user