]> www.ginac.de Git - cln.git/blobdiff - src/float/lfloat/elem/cl_LF_scale.cc
Extend the exponent range from 32 bits to 64 bits on selected platforms.
[cln.git] / src / float / lfloat / elem / cl_LF_scale.cc
index 7bb826bb33c255af5a6b502c0ae0d77277d84df1..7a2738f2b19b68152f9c2e908dbdaf7a98223fff 100644 (file)
@@ -4,7 +4,7 @@
 #include "cl_sysdep.h"
 
 // Specification.
-#include "cl_lfloat.h"
+#include "cln/lfloat.h"
 
 
 // Implementation.
@@ -13,7 +13,9 @@
 #include "cl_LF_impl.h"
 #include "cl_F.h"
 
-const cl_LF scale_float (const cl_LF& x, sintL delta)
+namespace cln {
+
+const cl_LF scale_float (const cl_LF& x, sintC delta)
 {
   // Methode:
   // delta=0 -> x als Ergebnis
@@ -21,9 +23,9 @@ const cl_LF scale_float (const cl_LF& x, sintL delta)
   // delta muß ein Integer betragsmäßig <= LF_exp_high-LF_exp_low sein.
   // Neues LF mit um delta vergrößertem Exponenten bilden.
       if (delta == 0) { return x; } // delta=0 -> x als Ergebnis
-      var uintL uexp = TheLfloat(x)->expo;
+      var uintE uexp = TheLfloat(x)->expo;
       if (uexp==0) { return x; }
-      var uintL udelta = delta;
+      var uintE udelta = delta;
       if (delta >= 0) {
         // udelta = delta >=0
        if (   ((uexp = uexp+udelta) < udelta) // Exponent-Überlauf?
@@ -31,8 +33,8 @@ const cl_LF scale_float (const cl_LF& x, sintL delta)
           )
          { cl_error_floating_point_overflow(); }
       } else {
-        // delta <0, udelta = 2^32+delta
-       if (   ((uexp = uexp+udelta) >= udelta) // oder Exponent-Unterlauf?
+        // delta <0, udelta = 2^intEsize+delta
+       if (   ((uintE)(-(uexp = uexp+udelta)) <= (uintE)(-udelta)) // oder Exponent-Unterlauf?
            || (uexp < LF_exp_low) // oder Exponent zu klein?
           )
          { cl_error_floating_point_underflow(); }
@@ -40,3 +42,5 @@ const cl_LF scale_float (const cl_LF& x, sintL delta)
       var uintC len = TheLfloat(x)->len;
       return encode_LFu(TheLfloat(x)->sign,uexp,arrayMSDptr(TheLfloat(x)->data,len),len);
 }
+
+}  // namespace cln