Copyright © 2006 Edwin Steiner <edwin.steiner@gmx.net>

Number Formats

123 faa     unquoted hexadecimal
0xcafe      canonical hexadecimal
$FFFF       $-prefixed hexadecimal
100h        h-postfixed hexadecimal
'42         canonical decimal, must be quoted in hex mode
0o664       canonical octal
'0b1010     canonical binary, must be quoted in hex mode
0i1010      canonical binary, does not need a quote

Operators

+           addition
-           subtraction
*           multiplication
/           integer division
%           remainder
//          floor of real division
%%          modulo (zero or same sign as divisor)
&           bitwise AND
|           bitwise OR
^           bitwise XOR
unary -     negation
unary ~     complement
<<          shift left
>>          shift right
s>>         signed shift right
<<<         rotate left
>>>         rotate right
u*u         multiplication with zero/zero extension
s*u         multiplication with sign/zero extension
u*s         multiplication with zero/sign extension
s*s         multiplication with sign/sign extension
u/u         unsigned division
s/u         signed/unsigned division
u/s         unsigned/signed division
s/s         signed/signed division
:hi#        select high # bits
:lo#        select low # bits
:msb        select MSB
:lsb        select LSB
:#          select bit #
:#-#        select bit range (can use 'msb' and 'lsb' in place of #)
:(...)      select bit list, eg. :(0,5-msb)
[...]#      put in a box of # bits width
unary ^     unbox
unary ^s    unbox signed
<-          name binding
Note
The # in this list are decimal numbers that are regarded as quoted by bb — and therefore always interpreted as decimal. You cannot put expressions there.
Note
Many operators only exhibit their special behaviour when working on boxes (ie. values of fixed width).
Note
The division and remainder/modulo operators satisfy the following equations:
(a /  b) * b + (a %  b) == a
(a // b) * b + (a %% b) == a