Go to the Next or Previous section, the Detailed Contents, or the FS(E)L Home Page.


A.1.2 Numbers

Syntax

12 integer literal
m+n, m-n sum and difference
-m unary minus
m*n product
m/n, m%n quotient and remainder

Remarks

Integer arithmetic is defined to support values between -2147483647 and 2147483647 inclusive, that is those numbers representable by an underlying 32-bit representation (either signed or twos-complement). The effect of overflow is not defined: it may produce an error, or it may silently wrap in unpredictable ways and so should not be relied upon.

The division and remainder operations are defined so that, for all n except zero,

m = n*(m/n)+m%n
|m%n| < |n|
m%n >= 0 (provided n>0)

This states that for positive divisors, division rounds down and the remainder operation yields a positive result.

Floating point numbers (introduced experimentally for Pravda [Lowe93]) are not currently supported by FDR. Although the syntax for them is still enabled, it is not documented here. Note: the dot syntax used in communications (see A.3 Types) can make an expression look just like a floating-point number would in other languages (e.g., `3.1' is actually the pairing of two integers -- the dot is not a decimal point).

The new unary minus operator can cause some confusion with comments (see B.1 Changes from FDR1 to FDR2).


Go to the Next or Previous section, the Detailed Contents, or the FS(E)L Home Page.