std/num/float64▲toc

64-bit IEEE floating point numbers.

Also described as double precision or binary64 numbers in the standards. See also https://​en.​wikipedia.​org/​wiki/​Double-​precision_​floating-​point_​format.

fun (~=)( x : float64std/core/types/float64: V, y : float64std/core/types/float64: V ) : boolstd/core/types/bool: V

Return if two floats are nearly equal with respect to an epsilon of 8*flt-epsilonstd/num/float64/flt-epsilon: float64. See also nearly-eqstd/num/float64/nearly-eq: (x : float64, y : float64, epsilon : ?float64) -> bool which takes an explicit epsilon.

fun abs-max( x : float64std/core/types/float64: V, y : float64std/core/types/float64: V ) : float64std/core/types/float64: V

The maximum of the absolute values.

fun abs-max( xs : liststd/core/list: V -> V<float64std/core/types/float64: V> ) : float64std/core/types/float64: V

The maximum of a list of absolute values.

fun acos( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the arc-cosine of d.

fun acosh( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

The area hyperbolic cosine of d.

fun asin( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the arc-sine of d.

fun asinh( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

The area hyperbolic sine of d.

fun atan( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the arc-tangent of d.

fun atan2( x : float64std/core/types/float64: V, y : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the arc-tangent of a point (x,y).

fun atanh( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

The area hyperbolic tangent of d.

fun cbrt( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the cubic root of a value d Returns nanstd/num/float64/nan: float64 if d == nanstd/num/float64/nan: float64 or if d is negative. Returns inf if d == inf .

fun ceiling( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the smallest integer equal or larger than d.

fun compare( x : float64std/core/types/float64: V, y : float64std/core/types/float64: V ) : orderstd/core/types/order: V

Compare floats using a total ordering on the float64std/core/types/float64: V. The ordering follows the totalOrder predicate as defined in IEEE 754-2008 exactly. The values are ordered in following order: negative quiet nan, negative signaling nan, neginfstd/num/float64/neginf: float64, -finite, -0.0, +0.0, finite, posinfstd/num/float64/posinf: float64, signaling nan, and quiet nan.

fun cos( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the cosine of an angle in radians d.

fun cosh( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

The hyperbolic cosine of d.

fun decode( d : float64std/core/types/float64: V ) : (intstd/core/types/int: V, intstd/core/types/int: V)

Decode a float64 d into a tuple (m,e) of a mantissa m and exponent e such that m·2e = d exactly. The mantissa m is always either 0 or in the range [252, 253). See also frexpstd/num/float64/frexp: (x : float64) -> (float64, int).

fun deg( rad : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Convert radians to degrees.

fun encode( man : intstd/core/types/int: V, exp : intstd/core/types/int: V ) : float64std/core/types/float64: V

Create a float64 d given a mantissa man and exponent expstd/num/float64/exp: (p : float64) -> float64 such that man·2expstd/num/float64/exp: (p : float64) -> float64 = d exactly (if it is representable by a float64std/core/types/float64: V). See also ldexpstd/num/float64/ldexp: (x : float64, e : int) -> float64.

fun exp( p : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return e to the power of p.

fun exp10( p : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the 10 to the power of p.

fun exp2( p : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the 2 to the power of p.

fun exp2( e : intstd/core/types/int: V ) : float64std/core/types/float64: V

Calculate 2·e for an integer e. Uses efficient bit conversion for exponents between -1022 and 1023 and otherwise falls back to the regular exp2 function converting e to a float64.

fun expm1( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return expstd/num/float64/exp: (p : float64) -> float64(x - 1.0). Avoids rounding errors for values of x very close to 1.0.

fun f32( f : float64std/core/types/float64: V ) : float32std/core/types/float32: V

Short version of float32 for convenience, e.g. 1.337.f32std/num/float64/f32: (f : float64) -> float32. For example:

> 1.337.show-hex ++ " != " ++ 1.337.f32.float64.show-hex
   "0x1.5645A1CAC0831p+0 != 0x1.5645A2p+0"
   > 1.337.show-hex ++ " != " ++ 1.337.f32std/num/float64/f32: (f : float64) -> float32.float64.show-hex
   "0x1.5645A1CAC0831p+0 != 0x1.5645A2p+0"
   

.

fun ffraction( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the ‘floored’ fraction of d, always greater or equal to zero.
d.floorstd/num/float64/floor: (d : float64) -> float64 + d.ffractionstd/num/float64/ffraction: (d : float64) -> float64 === d
(-2.4).ffractionstd/num/float64/ffraction: (d : float64) -> float64 === 0.6.

fun float32( f : float64std/core/types/float64: V ) : float32std/core/types/float32: V

Round a float64std/core/types/float64: V to a float32std/core/types/float32: V.

fun float64( f : float32std/core/types/float32: V ) : float64std/core/types/float64: V

Extend a float32std/core/types/float32: V to a float64std/core/types/float64: V.

fun float64-from-bits( i : int64std/core/types/int64: V ) : float64std/core/types/float64: V

Low-level: create a float64std/core/types/float64: V from the given 64-bit integer.

fun float64-to-bits( d : float64std/core/types/float64: V ) : int64std/core/types/int64: V

Low-level: return the bits of a 64-bit float64std/core/types/float64: V as in int64std/core/types/int64: V.

fun floor( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the largest integer equal or less than d.

val flt-e: float64std/core/types/float64: V

The e) constant.

val flt-epsilon: float64std/core/types/float64: V

Machine epsilon: the difference between 1.0 and the next representable float64std/core/types/float64: V value.

val flt-euler: float64std/core/types/float64: V

 Euler's constant.

val flt-ln10: float64std/core/types/float64: V

The natural logarithm of 10.

val flt-ln2: float64std/core/types/float64: V

The natural logarithm of 2.

val flt-log10e: float64std/core/types/float64: V

The base-10 logarithm of e.

val flt-log2e: float64std/core/types/float64: V

The base-2 logarithm of e.

val flt-max: float64std/core/types/float64: V

Maximum float64 value.

val flt-max-prec: intstd/core/types/int: V

maximal precision in decimal digits of a float64std/core/types/float64: V.

val flt-min: float64std/core/types/float64: V

Smallest positive normalized float64 value.

val flt-pi: float64std/core/types/float64: V

π.

val flt-pi2: float64std/core/types/float64: V

π/2.

val flt-pi34: float64std/core/types/float64: V

3π/4.

val flt-pi4: float64std/core/types/float64: V

π/4.

val flt-sqrt12: float64std/core/types/float64: V

1.0 / sqrtstd/num/float64/sqrt: (d : float64) -> float64(2.0) (= sqrtstd/num/float64/sqrt: (d : float64) -> float64(0.5)).

val flt-sqrt2: float64std/core/types/float64: V

The square-root of 2.

val flt-true-min: float64std/core/types/float64: V

Smallest positive subnormal value (i.e. DBL_TRUE_MIN).

val flt-twopi: float64std/core/types/float64: V

2π.

fun fmadd( x : float64std/core/types/float64: V, y : float64std/core/types/float64: V, z : float64std/core/types/float64: V ) : float64std/core/types/float64: V

fused multiply-add. Computes (x*y)+z as if to infinite precision with only the final result rounded back to a float64std/core/types/float64: V.

fun fraction( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the fractional part of a float64std/core/types/float64: V d.
d.truncate + d.fractionstd/num/float64/fraction: (d : float64) -> float64 === d
(-2.4).fractionstd/num/float64/fraction: (d : float64) -> float64 === -0.4.

fun frexp( x : float64std/core/types/float64: V ) : (float64std/core/types/float64: V, intstd/core/types/int: V)

‘Fraction/exponent’: return the normalized fraction f and exponent expstd/num/float64/exp: (p : float64) -> float64 for a number x such that x == f·2expstd/num/float64/exp: (p : float64) -> float64. The absolute value of the fraction f is always in the range [0.5, 1.0), or one of 0.0, -0.0, neginfstd/num/float64/neginf: float64, posinfstd/num/float64/posinf: float64, or nanstd/num/float64/nan: float64. See also decodestd/num/float64/decode: (d : float64) -> (int, int) which decodes to an integer mantissa.

fun hypot( x : float64std/core/types/float64: V, y : float64std/core/types/float64: V ) : float64std/core/types/float64: V

The hypotenuse of x and y: sqrtstd/num/float64/sqrt: (d : float64) -> float64(x*x + y*y). Prevents overflow for large numbers.

fun hypot( x : float64std/core/types/float64: V, y : float64std/core/types/float64: V, z : float64std/core/types/float64: V ) : float64std/core/types/float64: V

The square root of the sum of the squares of three floats. Prevents overflow for large numbers.

fun hypot( xs : liststd/core/list: V -> V<float64std/core/types/float64: V> ) : float64std/core/types/float64: V

The square root of the sum of squares of a list of floats. Prevents overflow for large numbers and uses Kahan-Babuškan-Neumaier summation for precision.

fun is-finite( d : float64std/core/types/float64: V ) : boolstd/core/types/bool: V

Is this a finite number (i.e. not nanstd/num/float64/nan: float64 or infinity).

fun is-inf( d : float64std/core/types/float64: V ) : boolstd/core/types/bool: V

Is this value equal to negative or positive infinity ?

fun is-nan( d : float64std/core/types/float64: V ) : boolstd/core/types/bool: V

Is this value equal to NaN ?

fun is-neginf( d : float64std/core/types/float64: V ) : boolstd/core/types/bool: V

Is this value equal to negative infinity ?

fun is-negzero( d : float64std/core/types/float64: V ) : boolstd/core/types/bool: V

Is this a negative zero value?

fun is-posinf( d : float64std/core/types/float64: V ) : boolstd/core/types/bool: V

Is this value equal to positive infinity ?

fun is-subnormal( d : float64std/core/types/float64: V ) : boolstd/core/types/bool: V

Is this a subnormal value? (i.e. 0 < d.abs < flt-minstd/num/float64/flt-min: float64).

fun ldexp( x : float64std/core/types/float64: V, e : intstd/core/types/int: V ) : float64std/core/types/float64: V

‘Load exponent’: returns x·2e for a is-finitestd/num/float64/is-finite: (d : float64) -> bool x and otherwise x itself. See also encodestd/num/float64/encode: (man : int, exp : int) -> float64 which loads an integer mantissa.

fun ln( f : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the natural logarithm (in base e) of a float64std/core/types/float64: V f.

fun ln1p( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return lnstd/num/float64/ln: (f : float64) -> float64(1.0 + x). Avoids potential imprecision for small x where adding 1.0 explicitly may lead to rounding errors.

fun lnaddexp( x : float64std/core/types/float64: V, y : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Returns lnstd/num/float64/ln: (f : float64) -> float64(expstd/num/float64/exp: (p : float64) -> float64(x) + expstd/num/float64/exp: (p : float64) -> float64(y)). Avoids overlow/underflow errors.

fun log( f : float64std/core/types/float64: V, base : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the logarithm in base base of a float64std/core/types/float64: V f.

fun log10( f : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the logarithm in base 10 of a float64std/core/types/float64: V f.

fun log2( f : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the logarithm in base 2 of a float64std/core/types/float64: V f.

fun logaddexp2( x : float64std/core/types/float64: V, y : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Returns log2std/num/float64/log2: (f : float64) -> float64( exp2(x) + exp2(y) ). Avoids overlow/underflow errors.

val nan: float64std/core/types/float64: V

Represents a value that is not a number (NaN).

fun nearly-eq( x : float64std/core/types/float64: V, y : float64std/core/types/float64: V, epsilon : ?float64std/core/types/float64: V ) : boolstd/core/types/bool: V

Return if two floats are nearly equal with respect to some epsilon (=8*flt-epsilonstd/num/float64/flt-epsilon: float64). The epsilon is the nearest difference for numbers around 1.0. The routine automatically scales the epsilon for larger and smaller numbers, and for subnormal numbers.

val neginf: float64std/core/types/float64: V

Negative infinity.

fun next-down( x : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Returns the greatest float64std/core/types/float64: V less than x. This behaves exactly as nextDown in the IEEE 754-2008 standard. The identity x.next-downstd/num/float64/next-down: (x : float64) -> float64 == next-downstd/num/float64/next-down: (x : float64) -> float64(x) holds for all x. When x is finite x == x.next-downstd/num/float64/next-down: (x : float64) -> float64.next-upstd/num/float64/next-up: (x : float64) -> float64 also holds.

fun next-up( x : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Returns the least float64std/core/types/float64: V greater than x. This behaves exactly as nextUp in the IEEE 754-2008 standard. The identity x.next-upstd/num/float64/next-up: (x : float64) -> float64 == next-downstd/num/float64/next-down: (x : float64) -> float64(x) holds for all x. When x is finite x == x.next-upstd/num/float64/next-up: (x : float64) -> float64.next-downstd/num/float64/next-down: (x : float64) -> float64 also holds.

fun parse-float64( s : stringstd/core/types/string: V ) : maybestd/core/types/maybe: V -> V<float64std/core/types/float64: V>

Parse a float64 number. Can be “NaN”, “Inf(inity)” (case-insensitive), a fix-point number (1.2) or in scientific notation (-2.3e-5). Also allows floats in hexadecimal notation (0xA.Fp-10) that can be represented precisely (and are the preferred round trip format).

fun pdouble(): parsestd/text/parse/parse: HX float64std/core/types/float64: V
val pi: float64std/core/types/float64: V

π.

val posinf: float64std/core/types/float64: V

Positive infinity.

fun pow( d : float64std/core/types/float64: V, p : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the d raised to the power of p.

fun rad( deg : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Convert degrees to radians.

fun round( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Round a float64 to its nearest integral value. If the value is halfway between two integers, the value is rounded towards the even one.

fun round-to-prec( d : float64std/core/types/float64: V, prec : intstd/core/types/int: V ) : float64std/core/types/float64: V

Round a float64 to a specified precision. Rounds to the even number in case of a tie.
123.456.round-to-precstd/num/float64/round-to-prec: (d : float64, prec : int) -> float64(2) == 123.46
123.456.round-to-precstd/num/float64/round-to-prec: (d : float64, prec : int) -> float64(-1) == 120.0.

fun show-hex( d : float64std/core/types/float64: V, width : ?intstd/core/types/int: V, use-capitals : ?boolstd/core/types/bool: V, pre : ?stringstd/core/types/string: V ) : stringstd/core/types/string: V

Show a float64 in hexadecimal notation. An advantage of this format is that it precisely represents the float64std/core/types/float64: V and can reliably (and efficiently) be parsed back, i.e. d.show-hex.parse-float64std/num/float64/parse-float64: (s : string) -> maybe<float64> == Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(d). The significant is the hexadecimal fraction while the exponent after the p is the decimal power of 2. For example, 0xA.Fp-10 = (10 + 15/16)·2-10 (not 2-16!) = 0.01068115234375. Equivalently, 0xA.Fp-10 == 0x5.78p-9 == 0x2.BCp-8 == 0x1.5Ep-7.

> flt-min.show-hex
"0x1.0p-1022"
> 0.1.show-hex
"0x1.999999999999Ap-4"
> flt-max.show-hex
"0x1.FFFFFFFFFFFFFp+1023"
> -0.0.show-hex
"-0x0.0p+0"
> nan.show-hex
"NaN"
> 0.01068115234375.show-hex
"0x1.5Ep-7"
> flt-minstd/num/float64/flt-min: float64.show-hex
"0x1.0p-1022"
> 0.1.show-hex
"0x1.999999999999Ap-4"
> flt-maxstd/num/float64/flt-max: float64.show-hex
"0x1.FFFFFFFFFFFFFp+1023"
> -0.0.show-hex
"-0x0.0p+0"
> nanstd/num/float64/nan: float64.show-hex
"NaN"
> 0.01068115234375.show-hex
"0x1.5Ep-7"

.

fun sin( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the sine of an angle in radians d.

fun sinh( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

The hyperbolic sine of d.

fun sqr( x : float64std/core/types/float64: V ) : float64std/core/types/float64: V

The square of a float64.

fun sqrt( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the square root of a value d Returns nanstd/num/float64/nan: float64 if d == nanstd/num/float64/nan: float64 or if d is negative. Returns inf if d == inf .

fun sum( xs : liststd/core/list: V -> V<float64std/core/types/float64: V> ) : float64std/core/types/float64: V

Return the sum of a list of floats. Uses Kahan-Babuškan-Neumaier summation to minimize rounding errors. This is more precise as Kahan summation and about as fast.
[1.0e3,1.0e97,1.0e3,-1.0e97].sum == 2000.0
while
[1.0e3,1.0e97,1.0e3,-1.0e97].foldlstd/core/foldl: forall<a,b,e> (list<a>, b, (b, a) -> e b) -> e b(0.0,(+)) == 0.0 (!)
A. Neumaier, Rundungsfehleranalyse einiger Verfahren zur Summation endlicher Summen. Math. Mechanik, 54:39–51, 1974.

fun tan( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the tangent of an angle in radians d.

fun tanh( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

The hyperbolic tangent of d.

fun truncate( d : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return the integral part of a float64std/core/types/float64: V d . If d >= 0.0 , return the largest integer equal or less to d , If d < 0.0 , return the smallest integer equal or larger to d .

fun with-sign-of( x : float64std/core/types/float64: V, y : float64std/core/types/float64: V ) : float64std/core/types/float64: V

Return x with the sign of y.

private import std/core/typesstd/core/types, std/core/hndstd/core/hnd, std/corestd/core, std/text/parsestd/text/parse, std/num/int64std/num/int64