Literals and operators
Integers 1
, floating-Point numbers 1.2
, characters 'a'
, strings "abc"
, booleans true
and the nulltype abyss
can be expressed using literals.
Integers can also be expressed using octal, binary or hexadecimal 0x00
, 0o00
, 0b00
.
Numeric literals can directly be typed using the suffixes i<number of bits>
, u<number of bits>
or f<number of bits>
.
Operators and upcasting are similar to other C-likes, with the addition of the power operator ^
.
Tty.WriteLn("1 + 2 = ${1u32 + 2}")
Tty.WriteLn("1 - 2 = ${1i32 - 2}")
Tty.WriteLn("true AND false is ${true && false}")
Tty.WriteLn("true OR false is ${true || false}")
Tty.WriteLn("NOT true is ${!true}")
Tty.WriteLn("0011 AND 0101 is ${0b0011 & 0b0101}")
Tty.WriteLn("0011 OR 0101 is ${0b0011 | 0b0101}")
Tty.WriteLn("0011 XOR 0101 is ${0b0011 xor 0b0101}")
Tty.WriteLn("1 << 5 is ${1 << 5}")
Tty.WriteLn("0x80 >> 2 is {0x80 >> 2}")