]> www.ginac.de Git - cln.git/blobdiff - src/float/dfloat/cl_DF.h
Cater to the fact that g++ 4.3 will use a different naming for
[cln.git] / src / float / dfloat / cl_DF.h
index 2acace703219914ccc160a47bf08662b2dacf4cc..701a0b70258401bd08614d5805755ceb3e450788 100644 (file)
@@ -21,10 +21,18 @@ typedef // 64-bit float in IEEE format
          uint64
        #else
          // Sign/Exponent/MantissaHigh and MantissaLow
-         #if CL_CPU_BIG_ENDIAN_P
-           struct { uint32 semhi, mlo; }
+         #if defined(double_wordorder_bigendian_p)
+           #if double_wordorder_bigendian_p
+             struct { uint32 semhi, mlo; }
+           #else
+             struct { uint32 mlo, semhi; }
+           #endif
          #else
-           struct { uint32 mlo, semhi; }
+           #if CL_CPU_BIG_ENDIAN_P
+             struct { uint32 semhi, mlo; }
+           #else
+             struct { uint32 mlo, semhi; }
+           #endif
          #endif
        #endif
        dfloat;
@@ -100,7 +108,7 @@ inline cl_heap_dfloat* allocate_dfloat (uint32 semhi, uint32 mlo)
 #if (cl_word_size==64)
 // DF_decode(obj, zero_statement, sign=,exp=,mant=);
 // zerlegt ein Double-Float obj.
-// Ist obj=0.0, wird zero_statement ausgeführt.
+// Ist obj=0.0, wird zero_statement ausgeführt.
 // Sonst: cl_signean sign = Vorzeichen (0 = +, -1 = -),
 //        sintL exp = Exponent (vorzeichenbehaftet),
 //        uintQ mant = Mantisse (>= 2^DF_mant_len, < 2^(DF_mant_len+1))
@@ -119,7 +127,7 @@ inline cl_heap_dfloat* allocate_dfloat (uint32 semhi, uint32 mlo)
 #else
 // DF_decode2(obj, zero_statement, sign=,exp=,manthi=,mantlo=);
 // zerlegt ein Double-Float obj.
-// Ist obj=0.0, wird zero_statement ausgeführt.
+// Ist obj=0.0, wird zero_statement ausgeführt.
 // Sonst: cl_signean sign = Vorzeichen (0 = +, -1 = -),
 //        sintL exp = Exponent (vorzeichenbehaftet),
 //        uintL manthi,mantlo = Mantisse 2^32*manthi+mantlo
@@ -144,22 +152,22 @@ inline cl_heap_dfloat* allocate_dfloat (uint32 semhi, uint32 mlo)
 #if (cl_word_size==64)
 // encode_DF(sign,exp,mant)
 // liefert ein Double-Float.
-// > cl_signean sign: Vorzeichen, 0 für +, -1 für negativ.
+// > cl_signean sign: Vorzeichen, 0 für +, -1 für negativ.
 // > sintL exp: Exponent
 // > uintQ mant: Mantisse, sollte >= 2^DF_mant_len und < 2^(DF_mant_len+1) sein.
 // < cl_DF ergebnis: ein Double-Float
-// Der Exponent wird auf Überlauf/Unterlauf getestet.
+// Der Exponent wird auf Überlauf/Unterlauf getestet.
 inline const cl_DF encode_DF (cl_signean sign, sintL exp, uintQ mant)
 {
       if (exp < (sintL)(DF_exp_low-DF_exp_mid))
         { if (underflow_allowed())
-            { cl_error_floating_point_underflow(); }
+            { throw floating_point_underflow_exception(); }
             else
             { return cl_DF_0; }
         }
       else
       if (exp > (sintL)(DF_exp_high-DF_exp_mid))
-        { cl_error_floating_point_overflow(); }
+        { throw floating_point_overflow_exception(); }
       else
       return allocate_dfloat
         (  ((sint64)sign & bit(63))                  /* Vorzeichen */
@@ -170,23 +178,23 @@ inline const cl_DF encode_DF (cl_signean sign, sintL exp, uintQ mant)
 #else
 // encode_DF(sign,exp,manthi,mantlo)
 // liefert ein Double-Float.
-// > cl_signean sign: Vorzeichen, 0 für +, -1 für negativ.
+// > cl_signean sign: Vorzeichen, 0 für +, -1 für negativ.
 // > sintL exp: Exponent
 // > uintL manthi,mantlo: Mantisse 2^32*manthi+mantlo,
 //                        sollte >= 2^DF_mant_len und < 2^(DF_mant_len+1) sein.
 // < cl_DF ergebnis: ein Double-Float
-// Der Exponent wird auf Überlauf/Unterlauf getestet.
+// Der Exponent wird auf Überlauf/Unterlauf getestet.
 inline const cl_DF encode_DF (cl_signean sign, sintL exp, uintL manthi, uintL mantlo)
 {
       if (exp < (sintL)(DF_exp_low-DF_exp_mid))
         { if (underflow_allowed())
-            { cl_error_floating_point_underflow(); }
+            { throw floating_point_underflow_exception(); }
             else
             { return cl_DF_0; }
         }
       else
       if (exp > (sintL)(DF_exp_high-DF_exp_mid))
-        { cl_error_floating_point_overflow(); }
+        { throw floating_point_overflow_exception(); }
       else
       return allocate_dfloat
         (  ((sint32)sign & bit(31))                       /* Vorzeichen */
@@ -203,7 +211,7 @@ inline double DF_to_double (const cl_DF& obj)
 {
        return TheDfloat(obj)->representation.machine_double;
 }
-// Überprüfen und Einpacken eines von den 'double'-Routinen gelieferten
+// Überprüfen und Einpacken eines von den 'double'-Routinen gelieferten
 // IEEE-Floats.
 // Klassifikation:
 //   1 <= e <= 2046 : normalisierte Zahl
@@ -211,8 +219,8 @@ inline double DF_to_double (const cl_DF& obj)
 //   e=0, m=0: vorzeichenbehaftete 0.0
 //   e=2047, m=0: vorzeichenbehaftete Infinity
 //   e=2047, m/=0: NaN
-// Angabe der möglicherweise auftretenden Sonderfälle:
-//   maybe_overflow: Operation läuft über, liefert IEEE-Infinity
+// Angabe der möglicherweise auftretenden Sonderfälle:
+//   maybe_overflow: Operation läuft über, liefert IEEE-Infinity
 //   maybe_subnormal: Ergebnis sehr klein, liefert IEEE-subnormale Zahl
 //   maybe_underflow: Ergebnis sehr klein und /=0, liefert IEEE-Null
 //   maybe_divide_0: Ergebnis unbestimmt, liefert IEEE-Infinity
@@ -226,7 +234,7 @@ inline double DF_to_double (const cl_DF& obj)
               )                                                                \
               && underflow_allowed()                                   \
              )                                                         \
-            { cl_error_floating_point_underflow(); } /* subnormal oder noch kleiner -> Underflow */\
+            { throw floating_point_underflow_exception(); } /* subnormal oder noch kleiner -> Underflow */\
             else                                                       \
             { ergebnis_zuweisung cl_DF_0; } /* +/- 0.0 -> 0.0 */       \
         }                                                              \
@@ -234,12 +242,12 @@ inline double DF_to_double (const cl_DF& obj)
             && (((~_erg.eksplicit) & ((uint64)bit(DF_exp_len+DF_mant_len)-bit(DF_mant_len))) == 0) /* e=2047 ? */\
            )                                                           \
         { if (maybe_nan && !((_erg.eksplicit<<(64-DF_mant_len)) == 0)) \
-            { cl_error_division_by_0(); } /* NaN, also Singularität -> "Division durch 0" */\
+            { throw division_by_0_exception(); } /* NaN, also Singularität -> "Division durch 0" */\
           else /* Infinity */                                          \
           if (!maybe_overflow || maybe_divide_0)                       \
-            { cl_error_division_by_0(); } /* Infinity, Division durch 0 */\
+            { throw division_by_0_exception(); } /* Infinity, Division durch 0 */\
             else                                                       \
-            { cl_error_floating_point_overflow(); } /* Infinity, Overflow */\
+            { throw floating_point_overflow_exception(); } /* Infinity, Overflow */\
         }                                                              \
       else                                                             \
         { ergebnis_zuweisung allocate_dfloat(_erg.eksplicit); }                \
@@ -254,7 +262,7 @@ inline double DF_to_double (const cl_DF& obj)
               )   )                                                       \
               && underflow_allowed()                                      \
              )                                                            \
-            { cl_error_floating_point_underflow(); } /* subnormal oder noch kleiner -> Underflow */\
+            { throw floating_point_underflow_exception(); } /* subnormal oder noch kleiner -> Underflow */\
             else                                                          \
             { ergebnis_zuweisung cl_DF_0; } /* +/- 0.0 -> 0.0           */\
         }                                                                 \
@@ -262,12 +270,12 @@ inline double DF_to_double (const cl_DF& obj)
             && (((~_erg.eksplicit.semhi) & ((uint32)bit(DF_exp_len+DF_mant_len-32)-bit(DF_mant_len-32))) == 0) /* e=2047 ?  */\
            )                                                              \
         { if (maybe_nan && !(((_erg.eksplicit.semhi<<(64-DF_mant_len)) == 0) && (_erg.eksplicit.mlo==0))) \
-            { cl_error_division_by_0(); } /* NaN, also Singularität -> "Division durch 0"  */\
+            { throw division_by_0_exception(); } /* NaN, also Singularität -> "Division durch 0"  */\
           else /* Infinity                                              */\
           if (!maybe_overflow || maybe_divide_0)                          \
-            { cl_error_division_by_0(); } /* Infinity, Division durch 0 */\
+            { throw division_by_0_exception(); } /* Infinity, Division durch 0 */\
             else                                                          \
-            { cl_error_floating_point_overflow(); } /* Infinity, Overflow */\
+            { throw floating_point_overflow_exception(); } /* Infinity, Overflow */\
         }                                                                 \
       else                                                                \
         { ergebnis_zuweisung allocate_dfloat(_erg.eksplicit.semhi,_erg.eksplicit.mlo); }  \
@@ -276,7 +284,7 @@ inline double DF_to_double (const cl_DF& obj)
 #endif
 
 // Liefert zu einem Double-Float x : (futruncate x), ein DF.
-// x wird von der 0 weg zur nächsten ganzen Zahl gerundet.
+// x wird von der 0 weg zur nächsten ganzen Zahl gerundet.
 extern const cl_DF futruncate (const cl_DF& x);
 
 // DF_to_I(x) wandelt ein Double-Float x, das eine ganze Zahl darstellt,