There are two kinds of real numbers in ABC. real and int. A real is an approximation to any real number between approximiately -2^4000000000 and +2^4000000000. The accuracy of the approximation is determined by the precision setting. An int is any positive or negative integer. Conversion between reals and ints occurs automatically, with an exception occuring when there is a loss of precision.
Literal reals consist of one or more digits optionally followed by a decimal point and one or more digits. You can also specify an exponent by appending e to the number followed by a positive or negative whole number.
Some valid reals: 123, 123.45, 0.34, 3e6, 3e+6 (exactly the same as 3e6), 5.67e-2
Some invalid reals: .456 (all reals must begin with a digit)
Literal ints can be specified in one of 4 bases: binary, octal, decimal or hexadecimal. Decimal ints consist of a one or more digits. Binary ints consist of a series of one or more bits (1 or 0) followed by lowercase b. Octal ints consists of a series of octits (0-7) followed by lowercase o. Hexadecimal ints consist of a series of one or more hexits (0-9 A-F) followed by h.
Some valid ints: 123, 0, 0011b, 123o, FFAA123h
Some invalid ints: 123.2 (ints can't have fractional components), 1102b (invalid bit), 12FF (hex numbers must end in h)
Constant | Definition |
---|---|
pi | The circumference of any circle divided by its diameter, approximately 3.14 |
e | The base of the natural logarithm, approximately 2.718 |
Operator | Description | Examples |
---|---|---|
x + y | Addition | 3+6, 5+6+9, 5+(9+88) |
x - y | Subtraction | 8-9, 8--4, 8-9-7 |
x * y | Multiplication. You can ommit this operator. For example, (3)(6) is equivalent to 3*6 | 8*9, 7*-3 |
x / y | Division. Division by 0 will cause an exception | 8/9, 7/8/5 (this is (7/8)/5) |
x ^ y | x to the yth power. | 5^2, 10^-4 |
x rt y | xth root of y. | 2 rt 25 |
sqr x | Computes the sqaure root of a number. This is much faster than 2 rt x. If x is negative the result will be an imaginary number | sqr 25 |
cbr x | Computes the cube root of a number. This is just an alias for 3 rt x | cbr 27 |
frac x | Extracts the fractional component of x | frac 2.34 |
int x | Extracts the integer component of x | int 2.34 |
exp x | The exponential function. Much faster than e^x. | exp 2 |
ln x | The natural logarithm. | ln e |