From: Jacob Lifshay Date: Wed, 15 Mar 2023 08:46:44 +0000 (-0700) Subject: fix javascript conversion of huge values X-Git-Tag: opf_rfc_ls001_v3~162 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f2858bdeaaad58a97349ab70e153c730fb178f67;p=libreriscv.git fix javascript conversion of huge values the old code would convert 1e100 to -1 when it should have been 0. --- 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