Contents|Index|Previous|Next
Number
constants
as
distinguishes three kinds of numbers according to how they are stored in
the target machine.
-
Integers
are numbers that would fit into an int in the C language.
-
Bignums
are integers, but they are stored in more than 32 bits.
-
Flonums
are floating point numbers, described in .
Integers
A binary
integer is 0b
or 0B
followed by one or more of the binary digits, 01.
An
octal integer is 0 followed by zero or more of the octal digits (0,
1,
2,
3,
4,
5,
6,
7).
A decimal
integer starts with a non-zero digit followed by zero or more digits (0,
1,
2,
3,
4,
5,
6,
7,
8,
9).
A hexadecimal
integer is 0x,
or 0X,
followed by zero or more hexadecimal digits (A,
B,
C, D,
E,
F,
a,
b,
c,
d,
e,
f
and 0,
1,
2,
3,
4,
5,
6,
7,
8,
9).
Integers have the usual values. To denote a negative integer, use the prefix
operator (-),
discussed under expressions (see Prefix
operator).
Bignums
A bignum
has the same syntax and semantics as an integer except that the number
(or its negative) takes more than 32 bits to represent in binary. The distinction
is made because in some places integers are permitted while bignums are
not.
Flonums
A flonum
represents a floating point number. The translation is indirect: a decimal
floating point number from the text is converted by as
to a generic binary floating point number of more than sufficient precision.
This generic floating point number is converted to a particular computer’s
floating point format (or formats) by a portion of as
specialized to that computer.
A flonum
is written by using (in order) the following:
-
The digit 0.
(0
is optional on the HPPA.)
-
A letter, to tell as the rest
of the number is a flonum. e
is recommended. Case is not important.
-
On the H8/300, H8/500, Hitachi
SH, and AMD 29K architectures, the letter must be one of the letters: D,
F,
P,
R,
S,
or X
(in upper or lower case).
-
On the Intel 960 architecture,
the letter must be one of the letters: D,
F,
or T
(in upper or lower case).
-
On the HPPA architecture, the
letter must be E
(upper case only).
-
An optional sign: either +
or -.
-
An optional integer part: zero
or more decimal digits.
-
An optional fractional part:
(.)
followed by zero or more decimal digits.
-
An optional exponent, consisting
of:
-
An E
or e.
-
Optional sign: either +
or -.
-
One or more decimal digits.
At least
one of the integer part or the fractional part must be present. The floating
point number has the usual base-10 value.
as
does all processing using integers. Flonums are computed independently
of any floating point hardware in the computer running as.
Top|Contents|Index|Previous|Next