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:
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:
Number representation
Internally, Numbat uses 64-bit floating-point numbers to represent all numeric values. This limits precision to approximately 15–16 significant decimal digits. While this is sufficient for most scientific and engineering calculations, you might run into problems if you compute differences between very large integers and expect to get an exact integer result.
Future plans
We are planning to switch to an arbitrary-precision numeric type in the future. See issue #4 for details.