summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/03_stdlib/08_int
blob: a6b59233c4cd8014e1dbf7e481cd8bf3142c4c1c (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
33
34
35
36
37
38
39
40
41
42
The `int()` function converts the given value into a signed integer
value and returns the resulting number.

Returns `NaN` if the given argument is not convertible into a number.

Returns `NaN` if the conversion result is out of range.

-- Testcase --
{%
	printf("%.J\n", [
		int(),
		int(false),
		int(123),
		int(456.789),
		int(""),
		int("invalid"),
		int("deaf"),
		int("0x1000"),
		int("0xffffffffffffffff"),
		int("0177"),
		int("+145"),
		int("-96")
	]);
%}
-- End --

-- Expect stdout --
[
	0,
	0,
	123,
	456,
	0,
	"NaN",
	"NaN",
	4096,
	"NaN",
	127,
	"NaN",
	-96
]
-- End --