From: Richard Kreckel Date: Fri, 1 Nov 2019 19:37:24 +0000 (+0100) Subject: Make scale_float() not throw a floating_point_underflow_exception... X-Git-Tag: cln_1-3-5~6 X-Git-Url: https://www.ginac.de/CLN/cln.git//cln.git?a=commitdiff_plain;h=7fc414f148790c27e97e157f02d90edd2558f603;p=cln.git Make scale_float() not throw a floating_point_underflow_exception... ...if cl_inhibit_floating_point_underflow was set to true. Reported by Jan Rheinländer . --- diff --git a/src/float/lfloat/elem/cl_LF_scale.cc b/src/float/lfloat/elem/cl_LF_scale.cc index 9a2e467..916c677 100644 --- a/src/float/lfloat/elem/cl_LF_scale.cc +++ b/src/float/lfloat/elem/cl_LF_scale.cc @@ -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); diff --git a/src/float/lfloat/elem/cl_LF_scale_I.cc b/src/float/lfloat/elem/cl_LF_scale_I.cc index 2c97e04..a6c7ea9 100644 --- a/src/float/lfloat/elem/cl_LF_scale_I.cc +++ b/src/float/lfloat/elem/cl_LF_scale_I.cc @@ -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: