1 // Public float operations.
6 #include "cln/number.h"
7 #include "cln/float_class.h"
8 #include "cln/floatformat.h"
9 #include "cln/random.h"
10 #include "cln/integer_class.h"
11 #include "cln/sfloat_class.h"
12 #include "cln/ffloat_class.h"
13 #include "cln/dfloat_class.h"
14 #include "cln/lfloat_class.h"
18 CL_DEFINE_AS_CONVERSION(cl_F)
21 // Return type for integer_decode_float:
22 struct cl_idecoded_float {
27 cl_idecoded_float () {}
28 cl_idecoded_float (const cl_I& m, const cl_I& e, const cl_I& s) : mantissa(m), exponent(e), sign(s) {}
32 // zerop(x) testet, ob (= x 0).
33 extern cl_boolean zerop (const cl_F& x);
35 // minusp(x) testet, ob (< x 0).
36 extern cl_boolean minusp (const cl_F& x);
38 // plusp(x) testet, ob (> x 0).
39 extern cl_boolean plusp (const cl_F& x);
42 // cl_F_to_SF(x) wandelt ein Float x in ein Short-Float um und rundet dabei.
43 extern const cl_SF cl_F_to_SF (const cl_F& x);
45 // cl_F_to_FF(x) wandelt ein Float x in ein Single-Float um und rundet dabei.
46 extern const cl_FF cl_F_to_FF (const cl_F& x);
48 // cl_F_to_DF(x) wandelt ein Float x in ein Double-Float um und rundet dabei.
49 extern const cl_DF cl_F_to_DF (const cl_F& x);
51 // cl_F_to_LF(x,len) wandelt ein Float x in ein Long-Float mit len Digits um
53 // > uintC len: gewünschte Anzahl Digits, >=LF_minlen
54 extern const cl_LF cl_F_to_LF (const cl_F& x, uintC len);
57 // The default float format used when converting rational numbers to floats.
58 extern float_format_t default_float_format;
60 // Returns the smallest float format which guarantees at least n decimal digits
61 // in the mantissa (after the decimal point).
62 extern float_format_t float_format (uintL n);
64 // cl_float(x,y) wandelt ein Float x in das Float-Format des Floats y um
65 // und rundet dabei nötigenfalls.
67 // < ergebnis: (float x y)
68 extern const cl_F cl_float (const cl_F& x, const cl_F& y);
70 // cl_float(x,f) wandelt ein Float x in das Float-Format f um
71 // und rundet dabei nötigenfalls.
73 // > f: eine Float-Format-Spezifikation
74 // < ergebnis: (float x f)
75 extern const cl_F cl_float (const cl_F& x, float_format_t f);
77 // cl_float(x) wandelt eine reelle Zahl x in ein Float um
78 // und rundet dabei nötigenfalls.
79 // > x: eine reelle Zahl
80 // < ergebnis: (float x)
81 // Abhängig von default_float_format.
82 inline const cl_F cl_float (const cl_F& x) { return x; }
84 // cl_float(x,y) wandelt ein Integer x in das Float-Format des Floats y um
85 // und rundet dabei nötigenfalls.
88 // < ergebnis: (float x y)
89 extern const cl_F cl_float (const cl_I& x, const cl_F& y);
91 // cl_float(x,y) wandelt ein Integer x in das Float-Format f um
92 // und rundet dabei nötigenfalls.
94 // > f: eine Float-Format-Spezifikation
95 // < ergebnis: (float x f)
96 extern const cl_F cl_float (const cl_I& x, float_format_t f);
98 // cl_float(x) wandelt ein Integer x in ein Float um und rundet dabei.
100 // < ergebnis: (float x)
101 // Abhängig von default_float_format.
102 extern const cl_F cl_float (const cl_I& x);
104 // cl_float(x,y) wandelt eine rationale Zahl x in das Float-Format des
105 // Floats y um und rundet dabei nötigenfalls.
106 // > x: eine rationale Zahl
108 // < ergebnis: (float x y)
109 extern const cl_F cl_float (const cl_RA& x, const cl_F& y);
111 // cl_float(x,y) wandelt eine rationale Zahl x in das Float-Format f um
112 // und rundet dabei nötigenfalls.
113 // > x: eine rationale Zahl
114 // > f: eine Float-Format-Spezifikation
115 // < ergebnis: (float x f)
116 extern const cl_F cl_float (const cl_RA& x, float_format_t f);
118 // cl_float(x) wandelt eine rationale Zahl x in ein Float um und rundet dabei.
119 // > x: eine rationale Zahl
120 // < ergebnis: (float x)
121 // Abhängig von default_float_format.
122 extern const cl_F cl_float (const cl_RA& x);
124 // The C++ compilers are not clever enough to guess this:
125 inline const cl_F cl_float (int x, const cl_F& y)
126 { return cl_float(cl_I(x),y); }
127 inline const cl_F cl_float (unsigned int x, const cl_F& y)
128 { return cl_float(cl_I(x),y); }
129 inline const cl_F cl_float (int x, float_format_t y)
130 { return cl_float(cl_I(x),y); }
131 inline const cl_F cl_float (unsigned int x, float_format_t y)
132 { return cl_float(cl_I(x),y); }
133 inline const cl_F cl_float (int x)
134 { return cl_float(cl_I(x)); }
135 inline const cl_F cl_float (unsigned int x)
136 { return cl_float(cl_I(x)); }
137 // The C++ compilers could hardly guess the following:
138 inline const cl_F cl_float (float x, const cl_F& y)
139 { return cl_float(cl_FF(x),y); }
140 inline const cl_F cl_float (double x, const cl_F& y)
141 { return cl_float(cl_DF(x),y); }
142 inline const cl_F cl_float (float x, float_format_t y)
143 { return cl_float(cl_FF(x),y); }
144 inline const cl_F cl_float (double x, float_format_t y)
145 { return cl_float(cl_DF(x),y); }
146 inline const cl_F cl_float (float x)
147 { return cl_float(cl_FF(x)); }
148 inline const cl_F cl_float (double x)
149 { return cl_float(cl_DF(x)); }
152 // Liefert (- x), wo x ein Float ist.
153 extern const cl_F operator- (const cl_F& x);
155 // Liefert (+ x y), wo x und y Floats sind.
156 extern const cl_F operator+ (const cl_F& x, const cl_F& y);
157 // The C++ compilers could hardly guess the following:
158 inline const cl_F operator+ (const cl_RA& x, const cl_F& y)
159 { return cl_float(x,y) + y; }
160 inline const cl_F operator+ (const cl_I& x, const cl_F& y)
161 { return cl_float(x,y) + y; }
162 inline const cl_F operator+ (const cl_F& x, const cl_RA& y)
163 { return x + cl_float(y,x); }
164 inline const cl_F operator+ (const cl_F& x, const cl_I& y)
165 { return x + cl_float(y,x); }
166 // Dem C++-Compiler muß man nun auch das Folgende sagen:
167 inline const cl_F operator+ (const int x, const cl_F& y)
168 { return cl_I(x) + y; }
169 inline const cl_F operator+ (const unsigned int x, const cl_F& y)
170 { return cl_I(x) + y; }
171 inline const cl_F operator+ (const long x, const cl_F& y)
172 { return cl_I(x) + y; }
173 inline const cl_F operator+ (const unsigned long x, const cl_F& y)
174 { return cl_I(x) + y; }
175 inline const cl_F operator+ (const cl_F& x, const int y)
176 { return x + cl_I(y); }
177 inline const cl_F operator+ (const cl_F& x, const unsigned int y)
178 { return x + cl_I(y); }
179 inline const cl_F operator+ (const cl_F& x, const long y)
180 { return x + cl_I(y); }
181 inline const cl_F operator+ (const cl_F& x, const unsigned long y)
182 { return x + cl_I(y); }
184 // Liefert (- x y), wo x und y Floats sind.
185 extern const cl_F operator- (const cl_F& x, const cl_F& y);
186 // The C++ compilers could hardly guess the following:
187 inline const cl_F operator- (const cl_RA& x, const cl_F& y)
188 { return cl_float(x,y) - y; }
189 inline const cl_F operator- (const cl_I& x, const cl_F& y)
190 { return cl_float(x,y) - y; }
191 inline const cl_F operator- (const cl_F& x, const cl_RA& y)
192 { return x - cl_float(y,x); }
193 inline const cl_F operator- (const cl_F& x, const cl_I& y)
194 { return x - cl_float(y,x); }
195 // Dem C++-Compiler muß man nun auch das Folgende sagen:
196 inline const cl_F operator- (const int x, const cl_F& y)
197 { return cl_I(x) - y; }
198 inline const cl_F operator- (const unsigned int x, const cl_F& y)
199 { return cl_I(x) - y; }
200 inline const cl_F operator- (const long x, const cl_F& y)
201 { return cl_I(x) - y; }
202 inline const cl_F operator- (const unsigned long x, const cl_F& y)
203 { return cl_I(x) - y; }
204 inline const cl_F operator- (const cl_F& x, const int y)
205 { return x - cl_I(y); }
206 inline const cl_F operator- (const cl_F& x, const unsigned int y)
207 { return x - cl_I(y); }
208 inline const cl_F operator- (const cl_F& x, const long y)
209 { return x - cl_I(y); }
210 inline const cl_F operator- (const cl_F& x, const unsigned long y)
211 { return x - cl_I(y); }
213 // Liefert (* x y), wo x und y Floats sind.
214 extern const cl_F operator* (const cl_F& x, const cl_F& y);
215 // Spezialfall x oder y Integer oder rationale Zahl.
216 inline const cl_R operator* (const cl_F& x, const cl_I& y)
218 extern const cl_R cl_F_I_mul (const cl_F&, const cl_I&);
219 return cl_F_I_mul(x,y);
221 inline const cl_R operator* (const cl_I& x, const cl_F& y)
223 extern const cl_R cl_F_I_mul (const cl_F&, const cl_I&);
224 return cl_F_I_mul(y,x);
226 inline const cl_R operator* (const cl_F& x, const cl_RA& y)
228 extern const cl_R cl_F_RA_mul (const cl_F&, const cl_RA&);
229 return cl_F_RA_mul(x,y);
231 inline const cl_R operator* (const cl_RA& x, const cl_F& y)
233 extern const cl_R cl_F_RA_mul (const cl_F&, const cl_RA&);
234 return cl_F_RA_mul(y,x);
236 // Dem C++-Compiler muß man nun auch das Folgende sagen:
237 inline const cl_R operator* (const int x, const cl_F& y)
238 { return cl_I(x) * y; }
239 inline const cl_R operator* (const unsigned int x, const cl_F& y)
240 { return cl_I(x) * y; }
241 inline const cl_R operator* (const long x, const cl_F& y)
242 { return cl_I(x) * y; }
243 inline const cl_R operator* (const unsigned long x, const cl_F& y)
244 { return cl_I(x) * y; }
245 inline const cl_R operator* (const cl_F& x, const int y)
246 { return x * cl_I(y); }
247 inline const cl_R operator* (const cl_F& x, const unsigned int y)
248 { return x * cl_I(y); }
249 inline const cl_R operator* (const cl_F& x, const long y)
250 { return x * cl_I(y); }
251 inline const cl_R operator* (const cl_F& x, const unsigned long y)
252 { return x * cl_I(y); }
254 // Liefert (* x x), wo x ein Float ist.
255 extern const cl_F square (const cl_F& x);
257 // Liefert (/ x y), wo x und y Floats sind.
258 extern const cl_F operator/ (const cl_F& x, const cl_F& y);
259 // Liefert (/ x y), wo x und y ein Float und eine rationale Zahl sind.
260 extern const cl_F operator/ (const cl_F& x, const cl_RA& y);
261 extern const cl_F operator/ (const cl_F& x, const cl_I& y);
262 extern const cl_R operator/ (const cl_RA& x, const cl_F& y);
263 extern const cl_R operator/ (const cl_I& x, const cl_F& y);
264 // The C++ compilers could hardly guess the following:
265 inline const cl_F operator/ (const cl_F& x, const int y)
266 { return x / cl_I(y); }
267 inline const cl_F operator/ (const cl_F& x, const unsigned int y)
268 { return x / cl_I(y); }
269 inline const cl_F operator/ (const cl_F& x, const long y)
270 { return x / cl_I(y); }
271 inline const cl_F operator/ (const cl_F& x, const unsigned long y)
272 { return x / cl_I(y); }
273 inline const cl_R operator/ (const int x, const cl_F& y)
274 { return cl_I(x) / y; }
275 inline const cl_R operator/ (const unsigned int x, const cl_F& y)
276 { return cl_I(x) / y; }
277 inline const cl_R operator/ (const long x, const cl_F& y)
278 { return cl_I(x) / y; }
279 inline const cl_R operator/ (const unsigned long x, const cl_F& y)
280 { return cl_I(x) / y; }
282 // Liefert (abs x), wo x ein Float ist.
283 extern const cl_F abs (const cl_F& x);
285 // Liefert zu einem Float x>=0 : (sqrt x), ein Float.
286 extern const cl_F sqrt (const cl_F& x);
288 // recip(x) liefert (/ x), wo x ein Float ist.
289 extern const cl_F recip (const cl_F& x);
291 // (1+ x), wo x ein Float ist.
292 inline const cl_F plus1 (const cl_F& x) // { return x + cl_I(1); }
294 return x + cl_float(1,x);
297 // (1- x), wo x ein Float ist.
298 inline const cl_F minus1 (const cl_F& x) // { return x + cl_I(-1); }
300 return x + cl_float(-1,x);
303 // compare(x,y) vergleicht zwei Floats x und y.
304 // Ergebnis: 0 falls x=y, +1 falls x>y, -1 falls x<y.
305 extern cl_signean compare (const cl_F& x, const cl_F& y);
307 // equal_hashcode(x) liefert einen equal-invarianten Hashcode für x.
308 extern uint32 equal_hashcode (const cl_F& x);
310 inline bool operator== (const cl_F& x, const cl_F& y)
311 { return compare(x,y)==0; }
312 inline bool operator!= (const cl_F& x, const cl_F& y)
313 { return compare(x,y)!=0; }
314 inline bool operator<= (const cl_F& x, const cl_F& y)
315 { return compare(x,y)<=0; }
316 inline bool operator< (const cl_F& x, const cl_F& y)
317 { return compare(x,y)<0; }
318 inline bool operator>= (const cl_F& x, const cl_F& y)
319 { return compare(x,y)>=0; }
320 inline bool operator> (const cl_F& x, const cl_F& y)
321 { return compare(x,y)>0; }
324 // ffloor(x) liefert (ffloor x), wo x ein Float ist.
325 extern const cl_F ffloor (const cl_F& x);
327 // fceiling(x) liefert (fceiling x), wo x ein Float ist.
328 extern const cl_F fceiling (const cl_F& x);
330 // ftruncate(x) liefert (ftruncate x), wo x ein Float ist.
331 extern const cl_F ftruncate (const cl_F& x);
333 // fround(x) liefert (fround x), wo x ein Float ist.
334 extern const cl_F fround (const cl_F& x);
337 // Return type for frounding operators.
338 // x / y --> (q,r) with x = y*q+r.
344 cl_F_fdiv_t (const cl_F& q, const cl_F& r) : quotient(q), remainder(r) {}
347 // ffloor2(x) liefert (ffloor x), wo x ein F ist.
348 extern const cl_F_fdiv_t ffloor2 (const cl_F& x);
350 // fceiling2(x) liefert (fceiling x), wo x ein F ist.
351 extern const cl_F_fdiv_t fceiling2 (const cl_F& x);
353 // ftruncate2(x) liefert (ftruncate x), wo x ein F ist.
354 extern const cl_F_fdiv_t ftruncate2 (const cl_F& x);
356 // fround2(x) liefert (fround x), wo x ein F ist.
357 extern const cl_F_fdiv_t fround2 (const cl_F& x);
360 // Return type for rounding operators.
361 // x / y --> (q,r) with x = y*q+r.
367 cl_F_div_t (const cl_I& q, const cl_F& r) : quotient(q), remainder(r) {}
370 // floor2(x) liefert (floor x), wo x ein F ist.
371 extern const cl_F_div_t floor2 (const cl_F& x);
372 extern const cl_I floor1 (const cl_F& x);
374 // ceiling2(x) liefert (ceiling x), wo x ein F ist.
375 extern const cl_F_div_t ceiling2 (const cl_F& x);
376 extern const cl_I ceiling1 (const cl_F& x);
378 // truncate2(x) liefert (truncate x), wo x ein F ist.
379 extern const cl_F_div_t truncate2 (const cl_F& x);
380 extern const cl_I truncate1 (const cl_F& x);
382 // round2(x) liefert (round x), wo x ein F ist.
383 extern const cl_F_div_t round2 (const cl_F& x);
384 extern const cl_I round1 (const cl_F& x);
386 // floor2(x,y) liefert (floor x y), wo x und y Floats sind.
387 extern const cl_F_div_t floor2 (const cl_F& x, const cl_F& y);
388 inline const cl_I floor1 (const cl_F& x, const cl_F& y) { return floor1(x/y); }
390 // ceiling2(x,y) liefert (ceiling x y), wo x und y Floats sind.
391 extern const cl_F_div_t ceiling2 (const cl_F& x, const cl_F& y);
392 inline const cl_I ceiling1 (const cl_F& x, const cl_F& y) { return ceiling1(x/y); }
394 // truncate2(x,y) liefert (truncate x y), wo x und y Floats sind.
395 extern const cl_F_div_t truncate2 (const cl_F& x, const cl_F& y);
396 inline const cl_I truncate1 (const cl_F& x, const cl_F& y) { return truncate1(x/y); }
398 // round2(x,y) liefert (round x y), wo x und y Floats sind.
399 extern const cl_F_div_t round2 (const cl_F& x, const cl_F& y);
400 inline const cl_I round1 (const cl_F& x, const cl_F& y) { return round1(x/y); }
403 // Return type for decode_float:
404 struct decoded_float {
410 decoded_float (const cl_F& m, const cl_I& e, const cl_F& s) : mantissa(m), exponent(e), sign(s) {}
413 // decode_float(x) liefert zu einem Float x: (decode-float x).
414 // x = 0.0 liefert (0.0, 0, 1.0).
415 // x = (-1)^s * 2^e * m liefert ((-1)^0 * 2^0 * m, e als Integer, (-1)^s).
416 extern const decoded_float decode_float (const cl_F& x);
418 // float_exponent(x) liefert zu einem Float x:
419 // den Exponenten von (decode-float x).
420 // x = 0.0 liefert 0.
421 // x = (-1)^s * 2^e * m liefert e.
422 extern sintL float_exponent (const cl_F& x);
424 // float_radix(x) liefert (float-radix x), wo x ein Float ist.
425 inline sintL float_radix (const cl_F& x)
431 // float_sign(x) liefert (float-sign x), wo x ein Float ist.
432 extern const cl_F float_sign (const cl_F& x);
434 // float_sign(x,y) liefert (float-sign x y), wo x und y Floats sind.
435 extern const cl_F float_sign (const cl_F& x, const cl_F& y);
437 // float_digits(x) liefert (float-digits x), wo x ein Float ist.
438 // < ergebnis: ein uintL >0
439 extern uintL float_digits (const cl_F& x);
441 // float_precision(x) liefert (float-precision x), wo x ein Float ist.
442 // < ergebnis: ein uintL >=0
443 extern uintL float_precision (const cl_F& x);
445 // Returns the floating point format of a float.
446 inline float_format_t float_format (const cl_F& x)
447 { return (float_format_t) float_digits(x); }
450 // integer_decode_float(x) liefert zu einem Float x: (integer-decode-float x).
451 // x = 0.0 liefert (0, 0, 1).
452 // x = (-1)^s * 2^e * m bei Float-Precision p liefert
453 // (Mantisse 2^p * m als Integer, e-p als Integer, (-1)^s als Fixnum).
454 extern const cl_idecoded_float integer_decode_float (const cl_F& x);
457 // rational(x) liefert (rational x), wo x ein Float ist.
458 extern const cl_RA rational (const cl_F& x);
461 // scale_float(x,delta) liefert x*2^delta, wo x ein Float ist.
462 extern const cl_F scale_float (const cl_F& x, sintL delta);
463 extern const cl_F scale_float (const cl_F& x, const cl_I& delta);
466 // max(x,y) liefert (max x y), wo x und y Floats sind.
467 extern const cl_F max (const cl_F& x, const cl_F& y);
469 // min(x,y) liefert (min x y), wo x und y Floats sind.
470 extern const cl_F min (const cl_F& x, const cl_F& y);
472 // signum(x) liefert (signum x), wo x ein Float ist.
473 extern const cl_F signum (const cl_F& x);
476 // Returns the largest (most positive) floating point number in float format f.
477 extern const cl_F most_positive_float (float_format_t f);
478 //CL_REQUIRE(cl_F_mostpos)
480 // Returns the smallest (most negative) floating point number in float format f.
481 extern const cl_F most_negative_float (float_format_t f);
482 //CL_REQUIRE(cl_F_mostneg)
484 // Returns the least positive floating point number (i.e. > 0 but closest to 0)
485 // in float format f.
486 extern const cl_F least_positive_float (float_format_t f);
487 //CL_REQUIRE(cl_F_leastpos)
489 // Returns the least negative floating point number (i.e. < 0 but closest to 0)
490 // in float format f.
491 extern const cl_F least_negative_float (float_format_t f);
492 //CL_REQUIRE(cl_F_leastneg)
494 // Returns the smallest floating point number e > 0 such that 1+e != 1.
495 extern const cl_F float_epsilon (float_format_t f);
496 //CL_REQUIRE(cl_F_epspos)
498 // Returns the smallest floating point number e > 0 such that 1-e != 1.
499 extern const cl_F float_negative_epsilon (float_format_t f);
500 //CL_REQUIRE(cl_F_epsneg)
503 // Konversion zu einem C "float".
504 extern float float_approx (const cl_F& x);
506 // Konversion zu einem C "double".
507 extern double double_approx (const cl_F& x);
510 // Transcendental functions
513 // pi(y) liefert die Zahl pi im selben Float-Format wie y.
515 extern const cl_F pi (const cl_F& y);
517 // pi(y) liefert die Zahl pi im Float-Format f.
518 // > f: eine Float-Format-Spezifikation
519 extern const cl_F pi (float_format_t f);
521 // pi() liefert die Zahl pi im Default-Float-Format.
522 extern const cl_F pi (void);
524 //CL_REQUIRE(cl_F_pi_var)
527 // sin(x) liefert den Sinus (sin x) eines Float x.
528 extern const cl_F sin (const cl_F& x);
530 // cos(x) liefert den Cosinus (cos x) eines Float x.
531 extern const cl_F cos (const cl_F& x);
533 // Return type for cos_sin():
538 cos_sin_t (const cl_R& u, const cl_R& v) : cos (u), sin (v) {}
541 // cos_sin(x) liefert ((cos x),(sin x)), beide Werte.
542 extern const cos_sin_t cos_sin (const cl_F& x);
544 // tan(x) liefert den Tangens (tan x) eines Float x.
545 extern const cl_F tan (const cl_F& x);
548 // exp1(y) liefert die Zahl e = exp(1) im selben Float-Format wie y.
550 extern const cl_F exp1 (const cl_F& y);
552 // exp1(y) liefert die Zahl e = exp(1) im Float-Format f.
553 // > f: eine Float-Format-Spezifikation
554 extern const cl_F exp1 (float_format_t f);
556 // exp1() liefert die Zahl e = exp(1) im Default-Float-Format.
557 extern const cl_F exp1 (void);
559 //CL_REQUIRE(cl_F_exp1_var)
562 // ln(x) liefert zu einem Float x>0 die Zahl ln(x).
563 extern const cl_F ln (const cl_F& x);
564 // Spezialfall: x Long-Float -> Ergebnis Long-Float
565 inline const cl_LF ln (const cl_LF& x) { return The(cl_LF)(ln(The(cl_F)(x))); }
567 // exp(x) liefert zu einem Float x die Zahl exp(x).
568 extern const cl_F exp (const cl_F& x);
570 // sinh(x) liefert zu einem Float x die Zahl sinh(x).
571 extern const cl_F sinh (const cl_F& x);
573 // cosh(x) liefert zu einem Float x die Zahl cosh(x).
574 extern const cl_F cosh (const cl_F& x);
576 // Return type for cosh_sinh():
581 cosh_sinh_t (const cl_R& u, const cl_R& v) : cosh (u), sinh (v) {}
584 // cosh_sinh(x) liefert ((cosh x),(sinh x)), beide Werte.
585 extern const cosh_sinh_t cosh_sinh (const cl_F& x);
587 // tanh(x) liefert zu einem Float x die Zahl tanh(x).
588 extern const cl_F tanh (const cl_F& x);
591 // eulerconst(y) liefert die Eulersche Konstante
592 // im selben Float-Format wie y.
594 extern const cl_F eulerconst (const cl_F& y);
596 // eulerconst(y) liefert die Eulersche Konstante im Float-Format f.
597 // > f: eine Float-Format-Spezifikation
598 extern const cl_F eulerconst (float_format_t f);
600 // eulerconst() liefert die Eulersche Konstante im Default-Float-Format.
601 extern const cl_F eulerconst (void);
603 //CL_REQUIRE(cl_F_eulerconst_var)
606 // catalanconst(y) liefert die Catalansche Konstante
607 // im selben Float-Format wie y.
609 extern const cl_F catalanconst (const cl_F& y);
611 // catalanconst(y) liefert die Catalansche Konstante im Float-Format f.
612 // > f: eine Float-Format-Spezifikation
613 extern const cl_F catalanconst (float_format_t f);
615 // catalanconst() liefert die Catalansche Konstante im Default-Float-Format.
616 extern const cl_F catalanconst (void);
618 //CL_REQUIRE(cl_F_catalanconst_var)
621 // zeta(s) returns the Riemann zeta function at s>1.
622 extern const cl_F zeta (int s, const cl_F& y);
623 extern const cl_F zeta (int s, float_format_t f);
624 extern const cl_F zeta (int s);
627 // random_F(randomstate,n) liefert zu einem Float n>0 ein zufälliges
628 // Float x mit 0 <= x < n.
629 // > randomstate: ein Random-State, wird verändert
630 extern const cl_F random_F (random_state& randomstate, const cl_F& n);
632 inline const cl_F random_F (const cl_F& n)
633 { return random_F(default_random_state,n); }
636 #ifdef WANT_OBFUSCATING_OPERATORS
637 // This could be optimized to use in-place operations.
638 inline cl_F& operator+= (cl_F& x, const cl_F& y) { return x = x + y; }
639 inline cl_F& operator++ /* prefix */ (cl_F& x) { return x = plus1(x); }
640 inline void operator++ /* postfix */ (cl_F& x, int dummy) { (void)dummy; x = plus1(x); }
641 inline cl_F& operator-= (cl_F& x, const cl_F& y) { return x = x - y; }
642 inline cl_F& operator-- /* prefix */ (cl_F& x) { return x = minus1(x); }
643 inline void operator-- /* postfix */ (cl_F& x, int dummy) { (void)dummy; x = minus1(x); }
644 inline cl_F& operator*= (cl_F& x, const cl_F& y) { return x = x * y; }
645 inline cl_F& operator/= (cl_F& x, const cl_F& y) { return x = x / y; }
652 // If this is true, floating point underflow returns zero instead of an error.
653 extern cl_boolean cl_inhibit_floating_point_underflow;
657 #endif /* _CL_FLOAT_H */