summaryrefslogtreecommitdiff
path: root/lib/math/scale2-impl.myr
diff options
context:
space:
mode:
Diffstat (limited to 'lib/math/scale2-impl.myr')
-rw-r--r--lib/math/scale2-impl.myr5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/math/scale2-impl.myr b/lib/math/scale2-impl.myr
index e0683a7..f75aac8 100644
--- a/lib/math/scale2-impl.myr
+++ b/lib/math/scale2-impl.myr
@@ -41,8 +41,11 @@ generic scale2gen = {n : bool, e : @i, s : @u, emin : @i, emax : @i, p : @u, m :
sprime++
;;
eprime = emin - 1
+ elif e + m < emin - p - 2
+ sprime = 0
+ eprime = emin - 1
elif e + m < emin
- sprime = s >> (emin - m - e)
+ sprime = s >> ((emin - m - e) : @u)
if need_round_away(0, (s : uint64), ((emin - m - e) : int64))
sprime++
;;