f64
f64
Fields
Constructors
prefix |:Any is[Inherited from numeric]¶[src]
absolute value using `|a|` built from a `prefix |` and `postfix |` as an operator
alias of `a.abs`
Due to the low precedence of `|`, this works also on expressions like `|a-b|`, even
with spaces `| a-b |`, `|a - b|`, `| a-b|` or `|a-b |`.
Nesting, however, does not work, e.g, `| - |a| |`, this requires parentheses `|(- |a|)|`.
alias of `a.abs`
Due to the low precedence of `|`, this works also on expressions like `|a-b|`, even
with spaces `| a-b |`, `|a - b|`, `| a-b|` or `|a-b |`.
Nesting, however, does not work, e.g, `| - |a| |`, this requires parentheses `|(- |a|)|`.
Functions
abs => numeric.this[Inherited from numeric]¶[src]
absolute value
acos => f64[Redefinition of float.acos]¶[src]
acosh => float.this[Inherited from float]¶[src]
as_i32 => i32[Inherited from float]¶[src]
convert a float value to i32 dropping any fraction.
the value must be in the range of i32
the value must be in the range of i32
as_i64 => i64[Redefinition of float.as_i64]¶[src]
Comment of float.as_i64
convert a float value to i64 dropping any fraction.the value must be in the range of i64
as_i64_lax => i64¶[src]
NaN is converted to 0
anything greater than i64.max as well as ∞ is i64.max
anything lower than i64.min as well as -∞ is i64.min
anything greater than i64.max as well as ∞ is i64.max
anything lower than i64.min as well as -∞ is i64.min
as_string => String[Redefinition of Any.as_string]¶[src]
convert this to a string.
as_string_decimals(fraction_digits i64) => String[Redefinition of float.as_string_decimals]¶[src]
convert this to a string with a fixed number of digits after the decimal point.
If the given values are unusable, the result is the same as `as_string`.
Overflows are technically possible, but floats become inaccurate long before that.
If the given values are unusable, the result is the same as `as_string`.
Overflows are technically possible, but floats become inaccurate long before that.
as_u128 => u128[Redefinition of float.as_u128]¶[src]
converts f64 to u128 by shifting mantissa bits based on the exponent
asin => f64[Redefinition of float.asin]¶[src]
asinh => float.this[Inherited from float]¶[src]
atan => f64[Redefinition of float.atan]¶[src]
atanh => float.this[Inherited from float]¶[src]
cast_to_u64 => u64¶[src]
casting bit representation to u64
ceil => float.this[Inherited from float]¶[src]
ceiling: the smallest integer greater or equal to this
cosh => f64[Redefinition of float.cosh]¶[src]
dynamic_apply(R:Any,F:Typed_Function R,f F) => R[Inherited from Any]¶[src]
dynamic_apply -- apply `f.call` to `Any.this`'s dynamic type and value
This can be used to perform operation on values depending on their dynamic
type.
Here is an example that takes a `Sequence Any` that may contain boxed values
of types `i32` and `f64`. We can now write a feature `get_f64` that extracts
these values converted to `f64` and build a function `sum` that sums them up
as follows:
This can be used to perform operation on values depending on their dynamic
type.
Here is an example that takes a `Sequence Any` that may contain boxed values
of types `i32` and `f64`. We can now write a feature `get_f64` that extracts
these values converted to `f64` and build a function `sum` that sums them up
as follows:
dynamic_type => Type[Inherited from Any]¶[src]
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
exponent => i64[Redefinition of float.exponent]¶[src]
the normalized exponent
exponent_biased => i64[Redefinition of float.exponent_biased]¶[src]
the biased exponent
fits_in_i64 => bool[Redefinition of float.fits_in_i64]¶[src]
does this `f64` value fit into an `i64`? Used in inherited
precondition of `as_i64`.
NOTE: We cannot compare with `i64.max.as_f64` since it rounds up to 2^63,
which does not fit.
`val` is `mantissa << sh`,
where sh is the number of bits to shift the mantissa left.
sh(shift) is capped at 63, larger values do not fit.
Then we set dynamic upper bound: 2^63 for negative numbers, 2^63-1 for positive.
if sh < 0, then |val| < 2^53, which always fits.
Otherwise we check `mantissa << sh <= max_abs` via right-shift to prevent overflow.
precondition of `as_i64`.
NOTE: We cannot compare with `i64.max.as_f64` since it rounds up to 2^63,
which does not fit.
`val` is `mantissa << sh`,
where sh is the number of bits to shift the mantissa left.
sh(shift) is capped at 63, larger values do not fit.
Then we set dynamic upper bound: 2^63 for negative numbers, 2^63-1 for positive.
if sh < 0, then |val| < 2^53, which always fits.
Otherwise we check `mantissa << sh <= max_abs` via right-shift to prevent overflow.
fits_in_u128 => bool[Redefinition of float.fits_in_u128]¶[src]
does this `f64` value fit into an `u128`? Used in inherited
precondition of `as_u128`.
precondition of `as_u128`.
floor => float.this[Inherited from float]¶[src]
floor: the greatest integer lower or equal to this
fract => f64[Redefinition of float.fract]¶[src]
the fraction of this floating point number
infix %(other f64) => f64[Redefinition of numeric.infix %]¶[src]
Comment of numeric.infix %
basic operations: 'infix %' (division remainder)infix *(other f64) => f64[Redefinition of numeric.infix *]¶[src]
Comment of numeric.infix *
basic operations: 'infix *' (multiplication)infix **(other f64) => f64[Redefinition of numeric.infix **]¶[src]
Comment of numeric.infix **
basic operations: 'infix **' (exponentiation)infix **?(other numeric.this) => option numeric.this[Inherited from numeric][Abstract feature]¶[src]
infix **^(other numeric.this) => numeric.this[Inherited from numeric][Abstract feature]¶[src]
infix *?(other numeric.this) => option numeric.this[Inherited from numeric]¶[src]
infix *^(other numeric.this) => numeric.this[Inherited from numeric]¶[src]
infix +(other f64) => f64[Redefinition of numeric.infix +]¶[src]
Comment of numeric.infix +
basic operations: 'infix +' (addition)infix +?(other numeric.this) => option numeric.this[Inherited from numeric]¶[src]
infix +^(other numeric.this) => numeric.this[Inherited from numeric]¶[src]
infix -(other f64) => f64[Redefinition of numeric.infix -]¶[src]
Comment of numeric.infix -
basic operations: 'infix -' (subtraction)infix -?(other numeric.this) => option numeric.this[Inherited from numeric]¶[src]
infix -^(other numeric.this) => numeric.this[Inherited from numeric]¶[src]
infix /(other f64) => f64[Redefinition of numeric.infix /]¶[src]
Comment of numeric.infix /
basic operations: 'infix /' (division)is_NaN => bool[Redefinition of float.is_NaN]¶[src]
Comment of float.is_NaN
is not a number?is_sign_bit_set => bool[Redefinition of float.is_sign_bit_set]¶[src]
is the sign bit set?
log(base float.this) => float.this[Inherited from float]¶[src]
logarithm with base `base`
mantissa => u64[Redefinition of float.mantissa]¶[src]
the normalized mantissa
prefix $ => String[Inherited from Any]¶[src]
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
prefix + => numeric.this[Inherited from numeric]¶[src]
basic operations: 'prefix +' (identity)
prefix +! => bool[Inherited from numeric]¶[src]
preconditions for basic operations: true if the operation's result is
representable and defined for the given values
default implementations all return `true` such that children have to
redefine these only for partial operations such as those resulting in
an overflow or that are undefined like a division by zero for most
types.
representable and defined for the given values
default implementations all return `true` such that children have to
redefine these only for partial operations such as those resulting in
an overflow or that are undefined like a division by zero for most
types.
prefix - => f64[Redefinition of numeric.prefix -]¶[src]
basic operations: 'prefix -' (negation)
prefix -? => option numeric.this[Inherited from numeric]¶[src]
overflow checking operations
prefix -^ => numeric.this[Inherited from numeric]¶[src]
saturating operations
round => float.this[Inherited from float]¶[src]
round floating point number
ties to away (0.5 => 1; -0.5 => -1; etc.)
NYI: PERFORMANCE: this could be made faster, see here:
https://cs.opensource.google/go/go/+/refs/tags/go1.18.1:src/math/floor.go;l=79
ties to away (0.5 => 1; -0.5 => -1; etc.)
NYI: PERFORMANCE: this could be made faster, see here:
https://cs.opensource.google/go/go/+/refs/tags/go1.18.1:src/math/floor.go;l=79
sign => i64[Inherited from numeric]¶[src]
sign function resulting in `-1`/`0`/`+1` depending on whether `numeric.this`
is less than, equal or greater than zero
is less than, equal or greater than zero
sinh => f64[Redefinition of float.sinh]¶[src]
sqrt => float.this[Inherited from float]¶[src]
square root alias
square_root => f64[Redefinition of float.square_root]¶[src]
Comment of float.square_root
square roottanh => f64[Redefinition of float.tanh]¶[src]
use_scientific_notation => bool[Redefinition of float.use_scientific_notation]¶[src]
true when the absolute value
is smaller than 0.001
or greater than 9_999_999
is smaller than 0.001
or greater than 9_999_999
Type Features
type.as_string => String[Inherited from Type]¶[src]
string representation of this type to be used for debugging.
result has the form "<name>", but this might change in the future
result has the form "<name>", but this might change in the future
type.atan2(y f64,x f64) => f64[Redefinition of float.type.atan2]¶[src]
atan(y/x) with a few special cases
see also: https://go.dev/src/math/atan2.go
see also: https://go.dev/src/math/atan2.go
type.bytes => i64[Redefinition of float.type.bytes]¶[src]
Comment of float.type.bytes
number of bytes required to store this valuetype.dynamic_type => Type[Inherited from Type]¶[src]
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types, so dynamic_type is redefined to just return
Type.type here.
Note: Typechecking is undecidable when 'type' is a type, Mark B. Reinhold, 1989
see: https://dspace.mit.edu/bitstream/handle/1721.1/149366/MIT-LCS-TR-458.pdf?sequence=6
endless hierarchy of types, so dynamic_type is redefined to just return
Type.type here.
Note: Typechecking is undecidable when 'type' is a type, Mark B. Reinhold, 1989
see: https://dspace.mit.edu/bitstream/handle/1721.1/149366/MIT-LCS-TR-458.pdf?sequence=6
type.epsilon => f64[Redefinition of float.type.epsilon]¶[src]
type.equality(a f64,b f64) => bool[Redefinition of property.orderable.type.equality]¶[src]
equality
This provides an equivalence relation in the mathematical
sense and therefore breaks the IEEE semantics. infix = should
be used for IEEE semantics.
The equivalence relation is provided by the usual comparison
of floating-point numbers, with the definition of NaN = NaN.
This provides an equivalence relation in the mathematical
sense and therefore breaks the IEEE semantics. infix = should
be used for IEEE semantics.
The equivalence relation is provided by the usual comparison
of floating-point numbers, with the definition of NaN = NaN.
type.exponent_bias => i64¶[src]
the exponent bias (the zero offset of the exponent)
type.exponent_bits => i64[Redefinition of float.type.exponent_bits]¶[src]
number of bits used for exponent
type.exponent_mask => u64¶[src]
mask for the bits that encode the exponent
(the mask is not shifted to the correct position)
(the mask is not shifted to the correct position)
type.exponent_range => interval i64[Inherited from float]¶[src]
type.from_i64(val i64) => f64[Redefinition of float.type.from_i64]¶[src]
Comment of float.type.from_i64
convert an i64 value to a floating point valueif the value cannot be represented exactly, the result is either
the nearest higher or nearest lower value
type.from_u32(v u32) => numeric.this[Inherited from numeric]¶[src]
the value corresponding to v in whatever integer implementation we have
we use a less *obvious* algorithm than induction via v-1 here to
reduce complexity to O(log(v)).
we use a less *obvious* algorithm than induction via v-1 here to
reduce complexity to O(log(v)).
type.hash_code(a f64) => u64[Redefinition of property.hashable.type.hash_code]¶[src]
create hash code from this number
special handling for floats:
although -0.0 and 0.0 are different in bit representation,
they are considered equal by both type.equality and IEEE
standard, hence they should have the same hash.
all NaNs are considered equal by type.equality (but not
the IEEE standard), so the hash of any NaN is the hash of
the "canonical" NaN.
special handling for floats:
although -0.0 and 0.0 are different in bit representation,
they are considered equal by both type.equality and IEEE
standard, hence they should have the same hash.
all NaNs are considered equal by type.equality (but not
the IEEE standard), so the hash of any NaN is the hash of
the "canonical" NaN.
type.infinity => float.this[Inherited from float]¶[src]
infinity
type.infix :(T:Any) => bool[Inherited from Type]¶[src]
Is this type assignable to a type parameter with constraint `T`?
The result of this is a compile-time constant that can be used to specialize
code for a particular type.
it is most useful in conjunction with preconditions or `if` statements as in
or
The result of this is a compile-time constant that can be used to specialize
code for a particular type.
it is most useful in conjunction with preconditions or `if` statements as in
or
type.lteq(a f64,b f64) => bool[Redefinition of property.partially_orderable.type.lteq]¶[src]
total order
This provides a total order in the mathematical sense and
therefore breaks the IEEE semantics. infix <= should be
used for IEEE semantics.
The total order is provided by the usual comparison of
floating-point numbers, with the definition that NaN <= x,
for any x (including x = NaN).
This provides a total order in the mathematical sense and
therefore breaks the IEEE semantics. infix <= should be
used for IEEE semantics.
The total order is provided by the usual comparison of
floating-point numbers, with the definition that NaN <= x,
for any x (including x = NaN).
type.mantissa_bits => i64[Inherited from float]¶[src]
the amount of bits that are used to encode the mantissa
type.mantissa_mask => u64¶[src]
mask for the bits that encode the mantissa
type.max => f64[Redefinition of float.type.max]¶[src]
type.max_exp => i64[Redefinition of float.type.max_exp]¶[src]
type.min_exp => i64[Redefinition of float.type.min_exp]¶[src]
type.min_positive => f64[Redefinition of float.type.min_positive]¶[src]
type.name => String[Inherited from Type]¶[src]
name of this type, including type parameters, e.g. 'option (list i32)'.
type.negative_infinity => float.this[Inherited from float]¶[src]
type.one => f64[Redefinition of numeric.type.one]¶[src]
identity element for 'infix *'
type.positive_infinity => float.this[Inherited from float]¶[src]
type.prefix $ => String[Inherited from Type]¶[src]
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
NYI: Redefinition allows the type feature to be distinguished from its normal counterpart, see #3913
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
NYI: Redefinition allows the type feature to be distinguished from its normal counterpart, see #3913
type.product => Monoid numeric.this[Inherited from numeric]¶[src]
monoid of numeric with infix * operation. Will create product of all elements
it is applied to.
it is applied to.
type.product_saturating => Monoid numeric.this[Inherited from numeric]¶[src]
monoid of numeric with infix *^ operation. Will create product of all elements
it is applied to, stopping at max/min value in case of overflow.
it is applied to, stopping at max/min value in case of overflow.
type.quiet_NaN => float.this[Inherited from float]¶[src]
non signaling not a number
type.significand_bits => i64[Redefinition of float.type.significand_bits]¶[src]
number of bits used for mantissa,
including leading '1' that is not actually stored
including leading '1' that is not actually stored
type.sum => Monoid numeric.this[Inherited from numeric]¶[src]
monoid of numeric with infix + operation. Will create sum of all elements it
is applied to.
is applied to.
type.sum_saturating => Monoid numeric.this[Inherited from numeric]¶[src]
monoid of numeric with infix +^ operation. Will create sum of all elements it
is applied to, stopping at max/min value in case of overflow.
is applied to, stopping at max/min value in case of overflow.
type.ten => numeric.this[Inherited from numeric]¶[src]
the constant '10' in whatever integer implementation we have
type.two => numeric.this[Inherited from numeric]¶[src]
the constant '2' in whatever integer implementation we have
type.type_value => Type[Inherited from Any]¶[src]
Get a type as a value.
This is a feature with the effect equivalent to Fuzion's `expr.type` call tail.
It is recommended to use `expr.type` and not `expr.type_value`.
`type_value` is here to show how this can be implemented and to illustrate the
difference to `dynamic_type`.
This is a feature with the effect equivalent to Fuzion's `expr.type` call tail.
It is recommended to use `expr.type` and not `expr.type_value`.
`type_value` is here to show how this can be implemented and to illustrate the
difference to `dynamic_type`.
type.zero => f64[Redefinition of numeric.type.zero]¶[src]
identity element for 'infix +'
type.π => f64[Redefinition of float.type.π]¶[src]
Comment of float.type.π
pi 3.14...type.ℇ => f64[Redefinition of float.type.ℇ]¶[src]
Comment of float.type.ℇ
eulers number 2.72..Applicable universe features
These are features in universe, that have an argument with a type constraint that matches this features type and can therefore be used with it.
equals(T:property.equatable,a T,b T) => bool¶[src]
equals -- feature that compares two values using the equality relation
defined in their type
defined in their type
hash(T:property.hashable,a T) => u64¶[src]
hash of a value
infix !=(T:property.equatable,a T,b T) => bool¶[src]
infix = -- infix operation as shorthand for 'equals'
infix <(T:property.orderable,a T,b T) => bool¶[src]
does this come strictly before other?
infix <=(T:property.partially_orderable,a T,b T) => bool¶[src]
infix <= -- infix operation as shorthand for 'lteq'
infix <>(T:property.orderable,a T,b T) => order¶[src]
three-way comparison between this and other.
result is < 0 if this < other
result is > 0 if this > other
result is = 0 if this = other
result is < 0 if this < other
result is > 0 if this > other
result is = 0 if this = other
infix =(T:property.equatable,a T,b T) => bool¶[src]
infix = -- infix operation as shorthand for 'equals'
infix >(T:property.orderable,a T,b T) => bool¶[src]
does this come strictly after other?
infix >=(T:property.orderable,a T,b T) => bool¶[src]
does this come after other?
infix ∈(T:property.equatable,a T,s container.Set T) => bool¶[src]
is `a` contained in `Set` `s`?
This should usually be called using type inference as in
This should usually be called using type inference as in
infix ∉(T:property.equatable,a T,s container.Set T) => bool¶[src]
is `a` not contained in `Set` `s`?
This should usually be called using type inference as in
This should usually be called using type inference as in
infix ≤(T:property.partially_orderable,a T,b T) => bool¶[src]
infix ≤ -- infix operation as shorthand for 'lteq'
infix ≥(T:property.orderable,a T,b T) => bool¶[src]
does this come after other?
infix ⋄(T:property.orderable,a T,b T) => order¶[src]
three-way comparison between this and other.
result is < 0 if this < other
result is > 0 if this > other
result is = 0 if this = other
result is < 0 if this < other
result is > 0 if this > other
result is = 0 if this = other
lteq(T:property.partially_orderable,a T,b T) => bool¶[src]
lteq -- feature that compares two values using the lteq relation
defined in their type
defined in their type
max(T:property.orderable,a T,b T) => T¶[src]
maximum of two values
memoize(MM:container.Mutable_Map T R,T:property.equatable,R:Any,f Unary R T) => Unary R T¶[src]
memoize `f`.
wraps f so that f will only be called once for every unique input.
The term "memoization" was coined by Donald Michie in 1968 and
is derived from the Latin word "memorandum" ("to be remembered"),
usually truncated as "memo" in American English, and thus carries
the meaning of "turning a function into something to be remembered".
https://en.wikipedia.org/wiki/Memoization
example:
wraps f so that f will only be called once for every unique input.
The term "memoization" was coined by Donald Michie in 1968 and
is derived from the Latin word "memorandum" ("to be remembered"),
usually truncated as "memo" in American English, and thus carries
the meaning of "turning a function into something to be remembered".
https://en.wikipedia.org/wiki/Memoization
example:
min(T:property.orderable,a T,b T) => T¶[src]
minimum of two values
0.099dev (GIT hash e2d5298d8107bb5fe79600fdb06a49bc75756344)
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227