From f2858bdeaaad58a97349ab70e153c730fb178f67 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Wed, 15 Mar 2023 01:46:44 -0700 Subject: [PATCH] fix javascript conversion of huge values the old code would convert 1e100 to -1 when it should have been 0. --- openpower/sv/int_fp_mv.mdwn | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openpower/sv/int_fp_mv.mdwn b/openpower/sv/int_fp_mv.mdwn index 5c0afa2de..a1c0981ee 100644 --- a/openpower/sv/int_fp_mv.mdwn +++ b/openpower/sv/int_fp_mv.mdwn @@ -636,9 +636,11 @@ switch(CVM) 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) 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 -- 2.30.2