File: Float.pmod

package info (click to toggle)
pike8.0 8.0.1956-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 60,580 kB
  • sloc: ansic: 259,734; xml: 36,320; makefile: 3,748; sh: 1,713; cpp: 1,349; awk: 1,036; lisp: 655; javascript: 468; asm: 242; objc: 240; pascal: 157; sed: 34
file content (83 lines) | stat: -rw-r--r-- 3,025 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

#pike __REAL_VERSION__

constant DIGITS_10 = __builtin.FLOAT_DIGITS_10;
constant MIN_10_EXP = __builtin.FLOAT_MIN_10_EXP;
constant MAX_10_EXP = __builtin.FLOAT_MAX_10_EXP;
constant MIN = __builtin.FLOAT_MIN;
constant MAX = __builtin.FLOAT_MAX;
constant EPSILON = __builtin.FLOAT_EPSILON;

//! @decl constant DIGITS_10;
//! @decl constant MIN_10_EXP;
//! @decl constant MAX_10_EXP;
//! @decl constant MIN;
//! @decl constant MAX;
//! @decl constant EPSILON;
//!
//! These constants define the limits for floats on the current
//! architecture:
//!
//! @dl
//! @item DIGITS_10
//!   The number of decimal digits that can be represented. Any number
//!   with this many decimal digits can be stored in a float and
//!   converted back to decimal form without change. @[DIGITS_10] is
//!   not less than @expr{6@}.
//! @item MIN_10_EXP
//! @item MAX_10_EXP
//!   Limits of the exponent in decimal base. 10 raised to any number
//!   within this range can be represented in normalized form.
//!   @[MIN_10_EXP] is not greater than @expr{-37@}. @[MAX_10_EXP] is
//!   not less than @expr{37@}.
//! @item MIN
//!   The smallest normalized float greater than zero. It's not
//!   greater than @expr{1e-37@}.
//! @item MAX
//!   The largest finite float. It's not less than @expr{1e37@}.
//! @item EPSILON
//!   The difference between 1 and the smallest value greater than 1
//!   that can be represented. It's not greater than @expr{1e-5@}.
//! @enddl
//!
//! @note
//! The size of the float type can be controlled when Pike is compiled
//! with the configure flags @expr{--with-double-precision@} and
//! @expr{--with-long-double-precision@}. The default is to use the
//! longest available float type that fits inside a pointer.

#if constant (__builtin.__FLOAT_PRECISION_FLOAT__)
constant FLOAT_PRECISION = __builtin.__FLOAT_PRECISION_FLOAT__;
#endif
#if constant (__builtin.__DOUBLE_PRECISION_FLOAT__)
constant DOUBLE_PRECISION = __builtin.__DOUBLE_PRECISION_FLOAT__;
#endif
#if constant (__builtin.__LONG_DOUBLE_PRECISION_FLOAT__)
constant LONG_DOUBLE_PRECISION = __builtin.__LONG_DOUBLE_PRECISION_FLOAT__;
#endif

//! @decl constant FLOAT_PRECISION;
//! @decl constant DOUBLE_PRECISION;
//! @decl constant LONG_DOUBLE_PRECISION;
//!
//! Tells which C compiler float type that is used for Pike floats.
//! Only one of these constants will exist (with the value @expr{1@})
//! at runtime.
//!
//! @dl
//! @item FLOAT_PRECISION
//!   The @expr{float@} type of the C compiler is used.
//! @item DOUBLE_PRECISION
//!   The @expr{double@} type of the C compiler is used.
//! @item LONG_DOUBLE_PRECISION
//!   The @expr{long double@} type of the C compiler is used.
//! @enddl
//!
//! @note
//! The float type can be controlled when Pike is compiled with the
//! configure flags @expr{--with-double-precision@} and
//! @expr{--with-long-double-precision@}. The default is to use the
//! longest available float type that fits inside a pointer.

//! Returns true if @[x] is nan.
int(0..1) isnan(float x) { return x!=x && floatp(x); }