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
.
The maximum of the absolute values.
The maximum of a list of absolute values.
Return the arc-cosine of d
.
The area hyperbolic cosine of d
.
Return the arc-sine of d
.
The area hyperbolic sine of d
.
Return the arc-tangent of d
.
Return the arc-tangent of a point (x
,y
).
The area hyperbolic tangent of d
.
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
.
Return the smallest integer equal or larger than d
.
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.
Return the cosine of an angle in radians d
.
The hyperbolic cosine of d
.
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)
.
Convert radians to degrees.
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
.
Return e to the power of p
.
Return the 10 to the power of p
.
Return the 2 to the power of p
.
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.
Return expstd/num/float64/exp: (p : float64) -> float64(x - 1.0)
.
Avoids rounding errors for values of x
very close to 1.0
.
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"
.
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
.
Extend a float32std/core/types/float32: V
to a float64std/core/types/float64: V
.
Low-level: create a float64std/core/types/float64: V
from the given 64-bit integer.
Low-level: return the bits of a 64-bit float64std/core/types/float64: V
as in int64std/core/types/int64: V
.
Return the largest integer equal or less than d
.
The e) constant.
Machine epsilon: the difference between 1.0 and the next representable float64std/core/types/float64: V
value.
The natural logarithm of 10.
The natural logarithm of 2.
The base-10 logarithm of e.
The base-2 logarithm of e.
Maximum float64 value.
maximal precision in decimal digits of a float64std/core/types/float64: V
.
Smallest positive normalized float64 value.
π/2.
3π/4.
π/4.
The square-root of 2.
Smallest positive subnormal value (i.e. DBL_TRUE_MIN
).
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
.
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
.
‘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.
The hypotenuse of x
and y
: sqrtstd/num/float64/sqrt: (d : float64) -> float64(x*x + y*y)
.
Prevents overflow for large numbers.
The square root of the sum of the squares of three floats. Prevents overflow for large numbers.
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.
Is this a finite number (i.e. not nanstd/num/float64/nan: float64
or infinity).
Is this value equal to negative or positive infinity ?
Is this value equal to NaN ?
Is this value equal to negative infinity ?
Is this a negative zero value?
Is this value equal to positive infinity ?
Is this a subnormal value?
(i.e. 0 < d.abs < flt-minstd/num/float64/flt-min: float64
).
‘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.
Return the natural logarithm (in base e) of a float64std/core/types/float64: V
f
.
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.
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.
Return the logarithm in base base
of a float64std/core/types/float64: V
f
.
Return the logarithm in base 10 of a float64std/core/types/float64: V
f
.
Return the logarithm in base 2 of a float64std/core/types/float64: V
f
.
Returns log2std/num/float64/log2: (f : float64) -> float64( exp2(x) + exp2(y) )
.
Avoids overlow/underflow errors.
Represents a value that is not a number (NaN).
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.
Negative infinity.
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.
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.
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).
π.
Positive infinity.
Return the d
raised to the power of p
.
Convert degrees to radians.
Round a float64 to its nearest integral value. If the value is halfway between two integers, the value is rounded towards the even one.
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
.
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"
.
Return the sine of an angle in radians d
.
The hyperbolic sine of d
.
The square of a float64.
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
.
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.
Return the tangent of an angle in radians d
.
The hyperbolic tangent of d
.
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
.
Return x
with the sign of y
.
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.