u16
u16
u16 -- 16-bit unsigned integer values
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
as_bytes => array u8[Inherited from wrap_around]¶[src]
this integer as an array of bytes (little endian)
as_i128 => i128[Redefinition of integer.as_i128]¶[src]
as_i16 => i16[Redefinition of integer.as_i16]¶[src]
as_i32 => i32[Redefinition of integer.as_i32]¶[src]
as_i64 => i64[Redefinition of integer.as_i64]¶[src]
as_i8 => i8[Redefinition of integer.as_i8]¶[src]
as_string => String[Inherited from integer]¶[src]
convert this to a decimal number in a string. If negative, add "-" as
the first character.
the first character.
as_string(base u32) => String[Inherited from integer]¶[src]
convert this to a number using the given base. If negative, add "-" as
the first character.
the first character.
as_string(len i64,base u32) => String[Inherited from integer]¶[src]
convert this to a number using the given base. If negative, add "-" as
the first character. Extend with leading "0" until the length is at
least len
the first character. Extend with leading "0" until the length is at
least len
as_u128 => u128[Redefinition of integer.as_u128]¶[src]
as_u32 => u32[Redefinition of integer.as_u32]¶[src]
as_u64 => u64[Redefinition of integer.as_u64]¶[src]
as_u8 => u8[Redefinition of integer.as_u8]¶[src]
Comment of integer.as_u8
this numeric value as an u8bin(len i64) => String[Inherited from integer]¶[src]
create binary representation with given number of digits.
dec(len i64) => String[Inherited from integer]¶[src]
create decimal representation with given number of digits.
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.
fits_in_i128 => bool[Redefinition of integer.fits_in_i128]¶[src]
fits_in_i16 => bool[Redefinition of integer.fits_in_i16]¶[src]
fits_in_i32 => bool[Redefinition of integer.fits_in_i32]¶[src]
fits_in_i64 => bool[Redefinition of integer.fits_in_i64]¶[src]
fits_in_i8 => bool[Redefinition of integer.fits_in_i8]¶[src]
fits_in_u128 => bool[Redefinition of integer.fits_in_u128]¶[src]
fits_in_u16 => bool[Redefinition of integer.fits_in_u16]¶[src]
fits_in_u32 => bool[Redefinition of integer.fits_in_u32]¶[src]
fits_in_u64 => bool[Redefinition of integer.fits_in_u64]¶[src]
fits_in_u8 => bool[Redefinition of integer.fits_in_u8]¶[src]
does this u16 fit into an u8?
gcd(b integer.this) => integer.this[Inherited from integer]¶[src]
greatest common divisor of this and b
note that this assumes zero to be divisible by any positive integer.
note that this assumes zero to be divisible by any positive integer.
hex(len i64) => String[Inherited from integer]¶[src]
create hexadecimal representation with given number of digits.
highest_one_bit => u16¶[src]
find the highest 1 bit in this integer and return integer with
this single bit set or 0 if this is 0.
this single bit set or 0 if this is 0.
infix %(other u16) => u16[Redefinition of numeric.infix %]¶[src]
Comment of numeric.infix %
basic operations: 'infix %' (division remainder)infix *(other num.wrap_around.this) => num.wrap_around.this[Inherited from wrap_around]¶[src]
multiplication, with check for overflow
infix *!(other num.wrap_around.this) => bool[Inherited from wrap_around]¶[src]
infix **(other num.wrap_around.this) => num.wrap_around.this[Inherited from wrap_around]¶[src]
exponentiation for positive exponent
'zero ** zero' is permitted and results in 'one'.
'zero ** zero' is permitted and results in 'one'.
infix **!(other num.wrap_around.this) => bool[Inherited from wrap_around]¶[src]
infix **?(other num.wrap_around.this) => option num.wrap_around.this[Inherited from wrap_around]¶[src]
exponentiation with overflow checking semantics
'zero **? zero' is permitted and results in 'one'.
'zero **? zero' is permitted and results in 'one'.
infix **^(other num.wrap_around.this) => num.wrap_around.this[Inherited from wrap_around]¶[src]
exponentiation with saturating semantics
'zero **^ zero' is permitted and results in 'one'.
'zero **^ zero' is permitted and results in 'one'.
infix **°(other num.wrap_around.this) => num.wrap_around.this[Inherited from wrap_around]¶[src]
exponentiation with wrap-around semantics
'zero **° zero' is permitted and results in 'one'.
'zero **° zero' is permitted and results in 'one'.
infix *?(other num.wrap_around.this) => option num.wrap_around.this[Inherited from wrap_around]¶[src]
infix *^(other num.wrap_around.this) => num.wrap_around.this[Inherited from wrap_around]¶[src]
infix +(other num.wrap_around.this) => num.wrap_around.this[Inherited from wrap_around]¶[src]
addition, with check for overflow
infix +!(other num.wrap_around.this) => bool[Inherited from wrap_around]¶[src]
infix +?(other num.wrap_around.this) => option num.wrap_around.this[Inherited from wrap_around]¶[src]
infix +^(other num.wrap_around.this) => num.wrap_around.this[Inherited from wrap_around]¶[src]
infix -(other num.wrap_around.this) => num.wrap_around.this[Inherited from wrap_around]¶[src]
subtraction, with check for overflow
infix -!(other num.wrap_around.this) => bool[Inherited from wrap_around]¶[src]
infix -?(other num.wrap_around.this) => option num.wrap_around.this[Inherited from wrap_around]¶[src]
infix -^(other num.wrap_around.this) => num.wrap_around.this[Inherited from wrap_around]¶[src]
infix ..(through property.interval.this) => interval property.interval.this[Inherited from interval]¶[src]
defining an integer interval from this to other, both inclusive
special cases of interval a..b:
special cases of interval a..b:
infix /(other u16) => u16[Redefinition of numeric.infix /]¶[src]
division and remainder with check for div-by-zero
infix /!(other integer.this) => bool[Inherited from integer]¶[src]
preconditions used in 'numeric' for basic operations: true if the
operation is permitted for the given values
operation is permitted for the given values
infix /-/(other integer.this) => num.fraction integer.this[Inherited from integer]¶[src]
create a fraction
infix ⁄(other integer.this) => num.fraction integer.this[Inherited from integer]¶[src]
create a fraction via unicode fraction slash \u2044 '⁄ '
is_bounded => bool[Inherited from wrap_around]¶[src]
check if this type of wrap_around is bounded
wrap_arounds are assumed to be a bound set by default, so
this returns true unless redefined by an implementation
wrap_arounds are assumed to be a bound set by default, so
this returns true unless redefined by an implementation
is_max => bool[Inherited from wrap_around]¶[src]
is_min => bool[Inherited from wrap_around]¶[src]
low8bits => u8[Redefinition of integer.low8bits]¶[src]
Comment of integer.low8bits
the least significant byte of this integeroct(len i64) => String[Inherited from integer]¶[src]
create octal representation with given number of digits.
ones_count => i64[Redefinition of num.wrap_around.ones_count]¶[src]
count the number of 1 bits in the binary representation of this
integer.
integer.
overflow_on_add(other u16) => bool[Redefinition of num.wrap_around.overflow_on_add]¶[src]
would addition + other cause an overflow or underflow?
overflow_on_exp(other num.wrap_around.this) => bool[Inherited from wrap_around]¶[src]
would exponentiation 'this ** other' cause an overflow?
overflow_on_mul(other u16) => bool[Redefinition of num.wrap_around.overflow_on_mul]¶[src]
would multiplication * other cause an overflow or underflow?
overflow_on_sub(other u16) => bool[Redefinition of num.wrap_around.overflow_on_sub]¶[src]
would subtraction - other cause an overflow or underflow?
postfix .. => interval property.interval.this[Inherited from interval]¶[src]
an infinite integer Sequence starting from this up to the maximum value
interval.this.max
interval.this.max
postfix ..∞ => interval property.interval.this[Inherited from interval]¶[src]
an infinite integer Sequence starting from this up to the maximum value
interval.this.max
NYI: CLEANUP: Eventually remove `postfix ..` or `postfix ..∞` in favor of the
other one, for now this is here to show that `∞` is a legal symbol in an operator.
interval.this.max
NYI: CLEANUP: Eventually remove `postfix ..` or `postfix ..∞` in favor of the
other one, for now this is here to show that `∞` is a legal symbol in an operator.
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 - => num.wrap_around.this[Inherited from wrap_around]¶[src]
negation, with check for overflow
prefix -! => bool[Inherited from wrap_around]¶[src]
preconditions used in 'numeric' for basic operations: true if the
operation is permitted for the given values
operation is permitted for the given values
prefix -? => option num.wrap_around.this[Inherited from wrap_around]¶[src]
overflow checking operations
prefix -^ => num.wrap_around.this[Inherited from wrap_around]¶[src]
saturating operations
prefix -° => u16[Redefinition of num.wrap_around.prefix -°]¶[src]
neg, add, sub, mul with wrap-around semantics
prefix ~ => num.wrap_around.this[Inherited from wrap_around]¶[src]
bitwise NOT
prefix ¬ => integer.this[Inherited from integer]¶[src]
bitwise NOT (Unicode alias)
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
trailing_zeros => i64¶[src]
count the number of trailing zeros in this integer.
underflow_on_add(other u16) => bool[Redefinition of num.wrap_around.underflow_on_add]¶[src]
underflow_on_mul(other u16) => bool[Redefinition of num.wrap_around.underflow_on_mul]¶[src]
underflow_on_sub(other u16) => bool[Redefinition of num.wrap_around.underflow_on_sub]¶[src]
wrapped_on_add(other num.wrap_around.this) => bool[Inherited from wrap_around]¶[src]
wrapped_on_mul(other num.wrap_around.this) => bool[Inherited from wrap_around]¶[src]
wrapped_on_neg => bool[Redefinition of num.wrap_around.wrapped_on_neg]¶[src]
would negation cause an overflow?
wrapped_on_sub(other num.wrap_around.this) => bool[Inherited from wrap_around]¶[src]
Type Features
type.all_bits_set => u16[Redefinition of num.wrap_around.type.all_bits_set]¶[src]
returns the number in whose bit representation all bits are ones
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.byte_size => i64[Inherited from wrap_around]¶[src]
how many bytes does this integer use?
type.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.equality(a u16,b u16) => bool[Redefinition of property.orderable.type.equality]¶[src]
equality
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 u16.this) => u64[Redefinition of property.hashable.type.hash_code]¶[src]
create hash code from this number
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 u16,b u16) => bool[Redefinition of property.partially_orderable.type.lteq]¶[src]
total order
type.max => u16[Redefinition of num.wrap_around.type.max]¶[src]
maximum
type.min => u16[Redefinition of num.wrap_around.type.min]¶[src]
minimum
type.name => String[Inherited from Type]¶[src]
name of this type, including type parameters, e.g. 'option (list i32)'.
type.one => u16[Redefinition of numeric.type.one]¶[src]
identity element for 'infix *'
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.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 => u16[Redefinition of numeric.type.zero]¶[src]
identity element for 'infix +'
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.
array(T:Any,I:integer,length I,init Unary T I) => array T¶[src]
array -- create initialized one-dimensional immutable array
array2(T:Any,I:integer,length0 I,length1 I,init Binary T I I) => array2 T¶[src]
array(length0, length1) -- two-dimensional immutable array
array provides two-dimensional immutable arrays. These are actually
one-dimensional immutable arrays with an additional access function with
two index parameters.
array provides two-dimensional immutable arrays. These are actually
one-dimensional immutable arrays with an additional access function with
two index parameters.
array3(T:Any,I:integer,length0 I,length1 I,length2 I,init Function T I I I) => array3 T¶[src]
array(length0, length1, length2) -- three-dimensional immutable array
array provides three-dimensional immutable arrays. These are actually
one-dimensional immutable arrays with an additional access function with
three index parameters.
array provides three-dimensional immutable arrays. These are actually
one-dimensional immutable arrays with an additional access function with
three index parameters.
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 20ecdcd8d62a0489c977cbb7295b8b8b142ee53e)