NAME

number – C compatable numbers for shell scripts

SYNOPSIS

aux/number [ –v ] [ –f fmt ] [ num... ]

DESCRIPTION

Number parses its argument as simple C expression containing the operators /, *, %, +, –, &, ^, and | on numbers parsed with strtoll (see atof(2)). Numbers may be decorated with a binary scale k, m, g, t, e, z, y using 1024 as a base. The result is printed as with print(2). The default format is %lld; alternate formats can be specified with –f. Formats are as in print(2). The special format « prints the result as a sequence of left–shifts and ors. The alternate format flag # combines strings of 1s. The format m prints the exact result using the same binary scale as above. The alternate format flag # allows rounding. The format width changes the base from 1024. All operations are preformed in 64–bit signed arithmetic.

EXAMPLE

Print out the number of 512–byte blocks in 1MB in hex
; aux/number –f '%#x' 1m/512
0x800

SOURCE

/sys/src/cmd/aux/number.c

SEE ALSO

dc(1), atof(2), getflags(8)

BUGS

Number is too fancy yet has no loops, functions, unsigned arithmetic or arbitrary precicison.