Next: Formal grammar for arithmetic expressions, Previous: Arithmetic expressions, Up: Arithmetic expressions [Contents][Index]

coNCePTuaL normally evaluates arithmetic expressions in
“integer context”, meaning that each subexpression is
truncated to the nearest integer after being evaluated. Hence,
‘`24/5*5`’ is ‘`20`’,
not ‘`24`’, because
‘`24/5*5`’ =
‘`(24/5)*5`’ =
‘`4*5`’ =
‘`20`’. There are a few situations, however,
in which coNCePTuaL evaluates expressions in “floating-point
context”, meaning that no truncation occurs:

- within an
`OUTPUTS`

statement (see Writing to standard output) - within a
`LOGS`

statement (see Writing to a log file) - within a
`BACKEND EXECUTES`

statement (see Injecting arbitrary code) - within a range in a
`FOR EACH`

statement (see Range loops) when coNCePTuaL is unable to find an arithmetic or geometric progression by evaluating the component <`expr`>s in integer context

Within any of the preceding statements, the expression
‘`24/5*5`’ evaluates to 24.
Furthermore, the expression ‘`24/5`’
evaluates to 4.8, which is a number that can’t be entered
directly in a coNCePTuaL program. (The language supports only
integral constants, as mentioned in Primitives.)

The coNCePTuaL language provides a special form called `REAL`

, which
resembles a single-argument function. When evaluated in
floating-point context, `REAL`

returns its argument
evaluated normally, as if ‘`REAL`’ were
absent. When evaluated in integer context, however, `REAL`

evalutes
its argument in floating-point context and then rounds the result
to the nearest integer. For example, in integer context,
‘`9/2 + 1/2`’ is
‘`4`’ while ‘`REAL(9/2 +
1/2)`’ is ‘`5`’.