From 8c97425fbc67b91d0c712947cc177485c55bea99 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Wed, 3 Mar 2021 18:31:38 +0100 Subject: [PATCH] b3d: add support for positive nan --- b3d.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/b3d.lua b/b3d.lua index 64c2984..5a57ec5 100644 --- a/b3d.lua +++ b/b3d.lua @@ -63,8 +63,9 @@ function read(stream) if mantissa == 0 then return sign * math.huge end - -- TODO differentiate quiet and signalling NaN as well as positive and negative - return 0/0 + -- Differentiating quiet and signalling nan is not possible in Lua, hence we don't have to do it + -- HACK ((0/0)^1) yields nan, 0/0 yields -nan + return sign == 1 and ((0/0)^1) or 0/0 end if exponent == 0 then -- subnormal value