L1VM - binary numbers
L1VM - binary numbers
Here I want to show the different number types you can use in Brackets. To define a HEX number you have to add a “&” symbol to the beginning of the number:
(set byte 1 bhex &FF)
To define a binary number using “0” and “1” you have to use something like this:
(set byte 1 bbin B$10000001)
Here is the full example:
// binary-2.l1com - Brackets - binary demo ;)
//
#include <intr.l1h>
(main func)
(set int64 1 zero 0)
// HEX numbers
(set byte 1 bhex &FF)
(set int16 1 i16hex &FFFF)
(set int32 1 i32hex &FFFFFFFF)
(set int64 1 i64hex &FFFFFFFFFFFFFFFF)
// binary numbers
(set byte 1 bbin B$10000001)
(set int16 1 i16bin W$1000000000000001)
// normal number
(set int64 1 i64norm 1234567890123456)
print_i (bhex)
print_n
print_i (i16hex)
print_n
print_i (i32hex)
print_n
print_i (i64hex)
print_n
print_n
print_i (bbin)
print_n
print_i (i16bin)
print_n
print_i (i64norm)
print_n
exit (zero)
(funcend)
Here is the output:
$ l1vm prog/binary-2 -q
255
65535
4294967295
9223372036854775807
129
32769
1234567890123456