blob: 245ae7044bd7ad309ec91d5b52afdcbd16e1cdc1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
% CPSC-FUNCTION-INT(7)
# NAME
cpsc-function-int - take the integer part of a number
# SYNOPSIS
```text
INT(value : REAL) RETURNS INTEGER
INT(value : INTEGER) RETURNS INTEGER
```
# DESCRIPTION
Built into the compiler, so it also works with `-no-std`.
Return the integer part of a REAL, truncating toward zero: `INT(27.5415)` is 27 and `INT(-27.9)` is -27. An INTEGER argument is returned unchanged. A NaN or a value outside the INTEGER range stops the program with a runtime error.
REAL never converts to INTEGER implicitly, so assignments, FOR bounds, array bounds and indices, arguments and RETURN values of type REAL are compile errors; wrap them in INT.
# EXAMPLE
```text
DECLARE Whole : INTEGER
Whole <- INT(27.5415)
OUTPUT Whole
```
# SEE ALSO
[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-div(7)](../keyword/cpsc-keyword-div.7.md).
|