File: number.md

package info (click to toggle)
surgescript 0.5.4.4-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,876 kB
  • sloc: ansic: 13,674; makefile: 16
file content (86 lines) | stat: -rw-r--r-- 1,461 bytes parent folder | download | duplicates (3)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Number
======

Routines for numbers. The Number object is not supposed to be used directly. The functions below are available for primitive values of the number type.

Example:

```
x = 2.toString(); // x is "2"
t = typeof(x); // t is "string"
```

**Note:** the SurgeScript Runtime stores numbers as 64-bit floating point values (following the IEEE 754 standard). Integer numbers are accurate up to 15 digits.

Functions
---------

#### valueOf

`valueOf()`

The primitive value of the number, i.e., the number itself.

*Returns*

The number.

#### toString

`toString()`

Converts the number to a string.

*Returns*

The number converted to a string.

#### equals

`equals(x)`

Compares the number to another number `x`. This routine performs a comparison between floating point numbers. It's recommended to use [Math.approximately()](/reference/math#approximately) instead.

*Arguments*

* `x`: number. The value to compare the number to.

*Returns*

Returns `true` if the numbers are equal.

#### isFinite

`isFinite()`

Checks if the number is finite.

*Available since:* SurgeScript 0.5.2

*Returns*

Returns `true` if the number is finite.

#### isNaN

`isNaN()`

Checks if the value is NaN (Not-a-Number).

*Available since:* SurgeScript 0.5.2

*Returns*

Returns `true` if the value is NaN.

#### isInteger

`isInteger()`

Checks if the number is an integer.

*Available since:* SurgeScript 0.5.2

*Returns*

Returns `true` if the number is an integer.