X-Git-Url: https://ginac.de/CLN/cln.git//cln.git?a=blobdiff_plain;f=include%2Fcln%2Ffloat.h;h=4f9945ced91796175fc7d174c801f858005b9dd8;hb=c84c6db5d56829d69083c819688a973867694a2a;hp=4c004a4579cbcaf662a5f2d67f3d6e610d6431b0;hpb=850abfde7f0d985ba01526c346bcd0d733562943;p=cln.git diff --git a/include/cln/float.h b/include/cln/float.h index 4c004a4..4f9945c 100644 --- a/include/cln/float.h +++ b/include/cln/float.h @@ -172,6 +172,10 @@ inline const cl_F operator+ (const long x, const cl_F& y) { return cl_I(x) + y; } inline const cl_F operator+ (const unsigned long x, const cl_F& y) { return cl_I(x) + y; } +inline const cl_F operator+ (const float x, const cl_F& y) + { return cl_F(x) + y; } +inline const cl_F operator+ (const double x, const cl_F& y) + { return cl_F(x) + y; } inline const cl_F operator+ (const cl_F& x, const int y) { return x + cl_I(y); } inline const cl_F operator+ (const cl_F& x, const unsigned int y) @@ -180,6 +184,10 @@ inline const cl_F operator+ (const cl_F& x, const long y) { return x + cl_I(y); } inline const cl_F operator+ (const cl_F& x, const unsigned long y) { return x + cl_I(y); } +inline const cl_F operator+ (const cl_F& x, const float y) + { return x + cl_F(y); } +inline const cl_F operator+ (const cl_F& x, const double y) + { return x + cl_F(y); } // Liefert (- x y), wo x und y Floats sind. extern const cl_F operator- (const cl_F& x, const cl_F& y); @@ -201,6 +209,10 @@ inline const cl_F operator- (const long x, const cl_F& y) { return cl_I(x) - y; } inline const cl_F operator- (const unsigned long x, const cl_F& y) { return cl_I(x) - y; } +inline const cl_F operator- (const float x, const cl_F& y) + { return cl_F(x) - y; } +inline const cl_F operator- (const double x, const cl_F& y) + { return cl_F(x) - y; } inline const cl_F operator- (const cl_F& x, const int y) { return x - cl_I(y); } inline const cl_F operator- (const cl_F& x, const unsigned int y) @@ -209,6 +221,10 @@ inline const cl_F operator- (const cl_F& x, const long y) { return x - cl_I(y); } inline const cl_F operator- (const cl_F& x, const unsigned long y) { return x - cl_I(y); } +inline const cl_F operator- (const cl_F& x, const float y) + { return x - cl_F(y); } +inline const cl_F operator- (const cl_F& x, const double y) + { return x - cl_F(y); } // Liefert (* x y), wo x und y Floats sind. extern const cl_F operator* (const cl_F& x, const cl_F& y); @@ -242,6 +258,10 @@ inline const cl_R operator* (const long x, const cl_F& y) { return cl_I(x) * y; } inline const cl_R operator* (const unsigned long x, const cl_F& y) { return cl_I(x) * y; } +inline const cl_F operator* (const float x, const cl_F& y) + { return cl_F(x) * y; } +inline const cl_F operator* (const double x, const cl_F& y) + { return cl_F(x) * y; } inline const cl_R operator* (const cl_F& x, const int y) { return x * cl_I(y); } inline const cl_R operator* (const cl_F& x, const unsigned int y) @@ -250,6 +270,10 @@ inline const cl_R operator* (const cl_F& x, const long y) { return x * cl_I(y); } inline const cl_R operator* (const cl_F& x, const unsigned long y) { return x * cl_I(y); } +inline const cl_F operator* (const cl_F& x, const float y) + { return x * cl_F(y); } +inline const cl_F operator* (const cl_F& x, const double y) + { return x * cl_F(y); } // Liefert (* x x), wo x ein Float ist. extern const cl_F square (const cl_F& x); @@ -270,6 +294,10 @@ inline const cl_F operator/ (const cl_F& x, const long y) { return x / cl_I(y); } inline const cl_F operator/ (const cl_F& x, const unsigned long y) { return x / cl_I(y); } +inline const cl_F operator/ (const cl_F& x, const float y) + { return x / cl_F(y); } +inline const cl_F operator/ (const cl_F& x, const double y) + { return x / cl_F(y); } inline const cl_R operator/ (const int x, const cl_F& y) { return cl_I(x) / y; } inline const cl_R operator/ (const unsigned int x, const cl_F& y) @@ -278,6 +306,10 @@ inline const cl_R operator/ (const long x, const cl_F& y) { return cl_I(x) / y; } inline const cl_R operator/ (const unsigned long x, const cl_F& y) { return cl_I(x) / y; } +inline const cl_F operator/ (const float x, const cl_F& y) + { return cl_F(x) / y; } +inline const cl_F operator/ (const double x, const cl_F& y) + { return cl_F(x) / y; } // Liefert (abs x), wo x ein Float ist. extern const cl_F abs (const cl_F& x); @@ -435,12 +467,12 @@ extern const cl_F float_sign (const cl_F& x); extern const cl_F float_sign (const cl_F& x, const cl_F& y); // float_digits(x) liefert (float-digits x), wo x ein Float ist. -// < ergebnis: ein uintL >0 -extern uintL float_digits (const cl_F& x); +// < ergebnis: ein uintC >0 +extern uintC float_digits (const cl_F& x); // float_precision(x) liefert (float-precision x), wo x ein Float ist. -// < ergebnis: ein uintL >=0 -extern uintL float_precision (const cl_F& x); +// < ergebnis: ein uintC >=0 +extern uintC float_precision (const cl_F& x); // Returns the floating point format of a float. inline float_format_t float_format (const cl_F& x) @@ -459,7 +491,7 @@ extern const cl_RA rational (const cl_F& x); // scale_float(x,delta) liefert x*2^delta, wo x ein Float ist. -extern const cl_F scale_float (const cl_F& x, sintL delta); +extern const cl_F scale_float (const cl_F& x, sintC delta); extern const cl_F scale_float (const cl_F& x, const cl_I& delta); @@ -636,13 +668,21 @@ inline const cl_F random_F (const cl_F& n) #ifdef WANT_OBFUSCATING_OPERATORS // This could be optimized to use in-place operations. inline cl_F& operator+= (cl_F& x, const cl_F& y) { return x = x + y; } +inline cl_F& operator+= (cl_F& x, const float y) { return x = x + y; } +inline cl_F& operator+= (cl_F& x, const double y) { return x = x + y; } inline cl_F& operator++ /* prefix */ (cl_F& x) { return x = plus1(x); } inline void operator++ /* postfix */ (cl_F& x, int dummy) { (void)dummy; x = plus1(x); } inline cl_F& operator-= (cl_F& x, const cl_F& y) { return x = x - y; } +inline cl_F& operator-= (cl_F& x, const float y) { return x = x - y; } +inline cl_F& operator-= (cl_F& x, const double y) { return x = x - y; } inline cl_F& operator-- /* prefix */ (cl_F& x) { return x = minus1(x); } inline void operator-- /* postfix */ (cl_F& x, int dummy) { (void)dummy; x = minus1(x); } inline cl_F& operator*= (cl_F& x, const cl_F& y) { return x = x * y; } +inline cl_F& operator*= (cl_F& x, const float y) { return x = x * y; } +inline cl_F& operator*= (cl_F& x, const double y) { return x = x * y; } inline cl_F& operator/= (cl_F& x, const cl_F& y) { return x = x / y; } +inline cl_F& operator/= (cl_F& x, const float y) { return x = x / y; } +inline cl_F& operator/= (cl_F& x, const double y) { return x = x / y; } #endif