result <- si64_CONVERT_FROM_BFP(range_max)
default: # JavaScript semantics
# CVM = 6, 7 are illegal instructions
- limit <- bfp_CONVERT_FROM_UI64(0xFFFF_FFFF_FFFF_FFFF)
+
+ # this works because the largest type we try to
+ # convert from has 53 significand bits, and the
+ # largest type we try to convert to has 64 bits,
+ # and the sum of those is strictly less than the
+ # 128 bits of the intermediate result.
+ limit <- bfp_CONVERT_FROM_UI128([1] * 128)
if IsInf(rnd) or IsNaN(rnd) then
result <- [0] * 64
else if bfp_COMPARE_GT(bfp_ABSOLUTE(rnd), limit) then
result <- [0] * 64
else
- # this works because the largest type we try to
- # convert from has 53 significand bits, and the
- # largest type we try to convert to has 64 bits,
- # and the sum of those is strictly less than the
- # 128 bits of the intermediate result.
result128 <- si128_CONVERT_FROM_BFP(rnd)
result <- result128[64:127] & js_mask