From 7fc414f148790c27e97e157f02d90edd2558f603 Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Fri, 1 Nov 2019 20:37:24 +0100 Subject: [PATCH] Make scale_float() not throw a floating_point_underflow_exception... MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ...if cl_inhibit_floating_point_underflow was set to true. Reported by Jan Rheinländer . --- src/float/lfloat/elem/cl_LF_scale.cc | 6 +++++- src/float/lfloat/elem/cl_LF_scale_I.cc | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) 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: -- 2.49.0