]> www.ginac.de Git - cln.git/commitdiff
Make scale_float() not throw a floating_point_underflow_exception...
authorRichard Kreckel <kreckel@ginac.de>
Fri, 1 Nov 2019 19:37:24 +0000 (20:37 +0100)
committerRichard Kreckel <kreckel@ginac.de>
Fri, 1 Nov 2019 19:39:45 +0000 (20:39 +0100)
...if cl_inhibit_floating_point_underflow was set to true.

Reported by Jan Rheinländer <jrheinlaender@gmx.de>.

src/float/lfloat/elem/cl_LF_scale.cc
src/float/lfloat/elem/cl_LF_scale_I.cc

index 9a2e467a1a6b848080a7b8acc33b84599a57965c..916c6778507de857ca2a454939156ce01ae65f9e 100644 (file)
@@ -37,7 +37,11 @@ const cl_LF scale_float (const cl_LF& x, sintC delta)
        if (   ((uintE)(-(uexp = uexp+udelta)) <= (uintE)(-udelta)) // oder Exponent-Unterlauf?
            || (uexp < LF_exp_low) // oder Exponent zu klein?
           )
-         { throw floating_point_underflow_exception(); }
+         { if (underflow_allowed())
+           { throw floating_point_underflow_exception(); }
+           else
+           { return encode_LF0(TheLfloat(x)->len); } // Ergebnis 0.0
+         }
       }
       var uintC len = TheLfloat(x)->len;
       return encode_LFu(TheLfloat(x)->sign,uexp,arrayMSDptr(TheLfloat(x)->data,len),len);
index 2c97e040101aea8f59136b4f238f6309aa1c6a95..a6c7ea987ae2951d2124ebbc6207938908c7ef77 100644 (file)
@@ -70,7 +70,11 @@ const cl_LF scale_float (const cl_LF& x, const cl_I& delta)
            || (uexp < LF_exp_low) // oder Exponent zu klein?
           )
          underflow:
-         { throw floating_point_underflow_exception(); }
+         { if (underflow_allowed())
+           { throw floating_point_underflow_exception(); }
+           else
+           { return encode_LF0(TheLfloat(x)->len); } // Ergebnis 0.0
+         }
        goto ok;
 
       ok: