diff options
-rw-r--r-- | fpu/softfloat.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fpu/softfloat.c b/fpu/softfloat.c index d90d79d777..70e0c40a1c 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -1878,6 +1878,12 @@ static FloatParts scalbn_decomposed(FloatParts a, int n, float_status *s) return return_nan(a, s); } if (a.cls == float_class_normal) { + /* The largest float type (even though not supported by FloatParts) + * is float128, which has a 15 bit exponent. Bounding N to 16 bits + * still allows rounding to infinity, without allowing overflow + * within the int32_t that backs FloatParts.exp. + */ + n = MIN(MAX(n, -0x10000), 0x10000); a.exp += n; } return a; |