From aee638e900531ec51d5166561361be01eef77adc Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Mon, 21 Sep 2015 21:15:48 +0200 Subject: [PATCH] Return denormals as 0 in (float)"number". Found by Pedro Oval. --- lslopt/lslbasefuncs.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lslopt/lslbasefuncs.py b/lslopt/lslbasefuncs.py index 171beb9..17b62e7 100644 --- a/lslopt/lslbasefuncs.py +++ b/lslopt/lslbasefuncs.py @@ -345,8 +345,14 @@ def InternalTypecast(val, out, InList, f32): if match is None: return 0.0 if match.group(1): - return F32(float.fromhex(match.group(0)), f32) - return F32(float(match.group(0)), f32) + ret = F32(float.fromhex(match.group(0)), f32) + else: + ret = F32(float(match.group(0)), f32) + if not lslcommon.LSO and abs(ret) < 1.1754943508222875e-38: + # Mono doesn't return denormals when using (float)"val" + # (but it returns them when using (vector)"") + ret = 0 + return ret if out == int: match = int_re.match(val) if match is None: