I:5 has as its value the string which is
produced by converting I with a field width of 5 characters. Thus it
is equivalent to an I5 format in FORTRAN. Similarly if X is a real
variable the expression X:10:4 produces the value of X formatted
in a FORTRAN F10.4 format (i.e. a field width of 10 characters, and
four decimal places). The ICL formatting is not precisely equivalent
to the FORTRAN form because ICL will extend the field width if a number
is too large to fit in the requested width.
ICL> = 1.234567:5:2
1.23
ICL> = 12.34567:5:2
12.35
ICL> = 123.4567:5:2
123.46
ICL> = 123456.7:5:2
123456.70
Integers can also be formatted in binary, octal, decimal or hexadecimal formats
using the functions BIN, OCT, DEC and HEX. These have the form
HEX(X,n,m) which would return a string of n characters containing
the number X with m significant digits. n and m may be omitted in which case
they default to the number of digits needed to represent a full 32 bit word.
Using these forms together with constants in various bases, ICL can be used to
perform conversions between various bases.
ICL> = %Xffff
65535
ICL> = hex(65535)
0000FFFF
ICL> = OCT(%XFF,5,5)
00377
ICL The Interactive Command Language for ADAM