aboutsummaryrefslogtreecommitdiff
path: root/doc/language/function/cpsc-function-num_to_str.7.md
blob: 8e895ee29bca25904b24f3e87ad8b91874577e19 (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

% CPSC-FUNCTION-NUM_TO_STR(7)

# NAME

cpsc-function-num_to_str - convert a number to text

# SYNOPSIS

```text
NUM_TO_STR(number : INTEGER or REAL) RETURNS STRING
```

# DESCRIPTION

Provided by the standard string library, loaded and linked by default.

Format INTEGER as signed decimal text and REAL in the same shortest round-trip form that OUTPUT prints. The text is the shortest decimal text that reads back as the same value (as Python's `repr`): fixed notation with at least one fractional digit when 1e-4 <= |x| < 1e16 (`2.0`, `87.5`, `0.0001`), otherwise scientific notation with an exponent of at least two digits (`1e-07`, `1.5e-07`, `1e+16`); special values print as `-0.0`, `inf`, `-inf` and `nan`.

# EXAMPLE

```text
OUTPUT NUM_TO_STR(42), " ", NUM_TO_STR(3.5)
```

# SEE ALSO

[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-function-str_to_num(7)](cpsc-function-str_to_num.7.md).