Types
| type | size | values |
|---|---|---|
int.short | 16 bits | -32768 to 32767 |
int | 32 bits | -2147483648 to 2147483647 |
int.long | 64 bits | about ±9.2 × 10¹⁸ |
unsigned int.short | 16 bits | 0 to 65535 |
unsigned int | 32 bits | 0 to 4294967295 |
unsigned int.long | 64 bits | 0 to 18446744073709551615 |
byte | 8 bits | 0 to 255 |
bool | true, false | |
char | one Unicode letter | |
string | text, see Strings |
The sizes are the same on Linux and Windows.
Numbers
a := 1_000_000 // _ is ignored
b := 0xFF
c := 0b1010
d := 0o17
print(a, b, c, d)
1000000 255 10 15
A whole number is an int. A number too big for int becomes an int.long:
small := 7
big := 3000000000
int.long sum := big + small
print(sum)
3000000007
Chars
A char holds one letter, in single quotes. Any Unicode letter works:
a := 'A'
alef := 'א'
newline := '\n'
smile := '\u{1F600}'
print(a, alef, smile)
A א 😀
Conversions
A smaller type turns into a bigger one by itself:
int.short s := 300
int.long l := s
print(l)
300
To go smaller, or between numbers and chars, convert with the type's name. The program checks that the value fits:
x := 300
print(int.short(x), int.long(x) * 2)
print(char(65), int('A'))
print(unsigned int(42), string(7) + "!")
300 600
A 65
42 7!
If the value doesn't fit, the program stops with an error:
error: this value doesn't fit in byte (0 to 255)
--> main.cfl:2:6
Signed and unsigned numbers of the same size don't mix; convert one side first.
double and float are planned for the next version.