Number notation
Numbers in Numbat can be written in the following forms:
- Integer notation
1234512_345— with decimal separators
- Floating point notation
0.234.234— without the leading zero
- Scientific notation
1.234e151.234e+151e-91.0e-9
- Non-decimal bases notation
0x2A— Hexadecimal0o52— Octal0b101010— Binary
- Non-finite numbers
NaN— Not a numberinf— Infinity
Convert numbers to other bases
You can use the bin, oct, dec and hex functions to convert numbers to binary, octal, decimal and hexadecimal bases,
respectively. You can call those using hex(2^16 - 1), but they are also available as targets of the conversion operator ->/to,
so you can write expressions like:
Examples:
0xffee -> bin
42 -> oct
2^16 - 1 -> hex
# using 'to':
0xffee to bin
You can also use base(b, n) to convert a number n to base b. Using the reverse function application operator |> you can write
this in a similar style to the previous examples:
273 |> base(3)
144 |> base(12)