Skip to content

Commit 89f32c6

Browse files
committed
Merge pull request #110107 from aaronfranke/fix-range-overflow
Fix Range scale overflow
2 parents 82ce2fd + efb580e commit 89f32c6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scene/gui/range.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ double Range::_snapped_r128(double p_value, double p_step) {
4444
// R128 is fixed-precision with 64 bits after the decimal point, but double already uses 53 of those,
4545
// so a step size finer than 2^-11 will lose precision, and in practice even 1e-3 can be problematic.
4646
// By rescaling the value and step, we can shift precision into the higher bits (effectively turning R128 into a makeshift float).
47-
const int decimals = 14 - Math::floor(std::log10(MAX(Math::abs(p_value), p_step)));
47+
const int decimals = MIN(18, 14 - Math::floor(std::log10(MAX(Math::abs(p_value), p_step))));
4848
const double scale = Math::pow(10.0, decimals);
4949
p_value *= scale;
5050
p_step *= scale;

0 commit comments

Comments
 (0)