Numbers¶
Cara supports the following number types on the language level:
Each of the numbered types denotes how wide it is: eg. UInt64 is 64 bits wide.
UInt types mean "unsigned int": a number without the sign bit.
Floats implement the IEEE 754 spec and specifically the binary32 and binary64 formats.
The types Int, UInt and Float are convenience aliases for Int64, UInt64 and Float64 respectively.
Numbers of different types are automatically promoted to the larger one when used together:
You can use underscore separators:
Integers can be written in the binary (0b), octal (0o) and hexadecimal (0x) bases:
Other bases
bin = 0b0000_1111_1000_0010 // = 3970 in base 10
oct = 0o777 // = 511 in base 10
hex = 0x11F8 // = 4600 in base 10
canBeNegative = -0b1101 // = -13 in base 10
Floats can be written in the scientific notation:
Scientific notation
x = 123.45e5 // 123.45 * 10^5 = 12_345_000
y = -123.45e-5 // -123.45 * 10^(-5) = -0.0012345
Standard library number types¶
There are more number types in the standard library:
Complexnumbers (TODO)BigInteger(TODO)BigDecimal(TODO)Fraction(TODO)