Integer numbers follow C-style format with support for decimal, binary (
0b), octal (
0o) and hex (
Integers can also be conveniently manipulated as bit-fields.
Both decimal and scientific notations can be used to represent floating-point numbers.
When rounding errors cannot be accepted, such as in financial calculations, use the decimal type, which is a fixed-precision floating-point number with no rounding errors.
_ separators can be added freely and are ignored within a number – except at the very
beginning or right after a decimal point (
|ending with decimal point
Decimal numbers represents a fixed-precision floating-point number which is popular with financial calculations and other usage scenarios where round-off errors are not acceptable.
Decimal numbers take up more space (16 bytes each) than a standard floating-point number (4-8 bytes) and is much slower in calculations due to the lack of CPU hardware support. Use it only when necessary.