To represent floating point numbers, objects of type real are used. Constants of type real are denoted as usual (e.g., -124.456); as for integer values, they have an arbitrary number of positive (+) or negative (-) signs, which are treated as prefix operators and resolved according to the usual rules (e.g., +0.1 = 0.1; --0.02 = 0.02).
The basic operations on reals are addition (+), subtraction (-), multiplication (*), and division (/); the precedence of these operators is as usual (unary - and + binding strongest, followed by * and /, and finally binary + and - with the weakest precedence). There are more predefined functions on reals, including trigonometric functions, roots, exponentiation, and logarithm.
To convert reals to integers, the functions floor and ceil can be used as well as the conversion function INT. For integer to real conversion multiplication by 1.0 or the conversion function REAL can be used. Automatic type conversion from integer to real takes place whenever a function or operation which expects a real value parameter is applied to an integer.
Attention!
Note, that scientific notation for real constants
(like 1.23E-3) is not supported by SALIERI.
When output by SALIERI, real values are always
represented with 8 decimals (where the last decimal
is rounded); however, usually a higher precision is used
internally. But inherent to the properties of real arithmetics
on computers in general, you can never absolutely rely
on the precision of real valued calculations (see example
below). If
absolute precisision is needed, integer
values should be used instead.
Unlike overflow situations for integers,
SALIERI is very sensitive with respect to real
numbers - the system might crash. Although the range of object
type real is very large, one should be careful with fast growing
functions like exp.
Example:
> 23.4
Result= 23.40000000
> -+23.4
Result= -23.40000000
> 7 + 10/3*12-1
Result= 46.00000000
> exp(3,2.5)
Result= 15.58845727
> exp(3,2.5)
Result= 15.58845727
> (0.3-0.2)*exp(10,10)
Result= 999999999.99999976
See also: +, -, *, /, INT, REAL, floor, ceil, Predefined Functions, Operators and Expressions.