Number
Numbers are a way to represent any ordinal limited by your computer's memory.
Cheddar's numbers support decimals, separators, bases, and implicit promotion.
The most basic form of a number in Cheddar are integers and decimals. Cheddar wraps both of these in a "Number" type. You can write numbers as you would in most languages:
1
123
123.456
.123
0.1
1.0
Often in programs you deal with large numbers. Numbers are often written with commas to distinguish the sections of the number. Cheddar provides a simple syntax for number separators,
_
. 123_456 // Same as 123456
1_2_3_4 // Same as 1234
1__2345 // same as 12345
As you can see, Cheddar does not enforce where you place your number separators.
You can type binary, octal, and hexadecimal literals in Cheddar:
0b1010 // *b*inary
0xFF // He*x*adecimal
0o0222 // *o*ctal
What's the zero at the beginning? That specified the amount of zeros to append to the integer section of the number. For example:
2b1 // equal to 0b100
1xF // equal to 0xF0
Last modified 3yr ago