Binary encodings of numbers
This is the successor of the [root:Rtypes] module
32 bit signed integer
64 bit signed integer
32 bit unsigned integer
64 bit unsigned integer
single precision float (IEEE "float")
double precision float (IEEE "double")
raised if a conversion can't be done
raised if string position out of range
mk_
<t> create integer values from character tuples. In these tuples
the MSB is the first component and the LSB the last.
dest_
<t> destroy integer values and returns the corresponding char
tuples.
Conversions from int to (u)int and vice versa.
On 32-bit computers, the type int
can hold 31-bit signed integers
(including the sign, i.e. one bit cannot be used).
On 64-bit computers, the type int
can hold 63-bit signed integers
(including the sign, i.e. one bit cannot be used).
The int_of_xxx
functions raise Cannot_represent
if the number to
convert is too big (or too small) to be represented as int
. Note
that this depends on the word size of your architecture.
Casts from uint4
/uint8
to int32
/int64
. Here, the sign is ignored and
simply considered as a bit.
The comparisons "=" and "<>" work for all numbers.
For signed integers, the operators "<", "<=", ">", and ">=" work, too. The unsigned integer type use representation that are not compatible with these operators, and the following functions need to be called.
For fp4
and fp8
there are no comparison functions - convert to
float
first and compare then.
Encode/decode numbers as strings. These functions exist in two flavors:
read_
<t> create integer values from the characters found at a
certain position in the string. Raises Out_of_range
if the position
is bad
write_
<t> copies the characters corresponding to the integer values
into the string at the given positions. Raises Out_of_range
if the
position is bad.