blob: a3a98ee81207c190d7b96622768755f083090c57 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
Zesstra715ec202025-07-09 22:18:31 +02002 int to_int(string)
3 int to_int(float)
4 int to_int(int)
5 int to_int(closure)
MG Mud User88f12472016-06-24 23:31:02 +02006
7 (int)<value>
8
Zesstra715ec202025-07-09 22:18:31 +02009DESCRIPTION
10 Floats are truncated to integer values, strings with leadings
11 digits are converted to integers up to the first non-digit.
12 lfun-closures are converted into their function index (not adjusted
13 for inheritance), variable closure are converted into their variable
14 index.
15 Integers are just returned.
MG Mud User88f12472016-06-24 23:31:02 +020016
Zesstra715ec202025-07-09 22:18:31 +020017 Regarding floats, it is important to keep rounding effects
18 in mind: to_int(3.1*10.0) does not return 31, but instead 30,
19 because internally the result of the multiplication is 30.999999.
MG Mud User88f12472016-06-24 23:31:02 +020020
Zesstra715ec202025-07-09 22:18:31 +020021 The function supports the '0x', '0o' and '0b' base prefixes.
MG Mud User88f12472016-06-24 23:31:02 +020022
Zesstra715ec202025-07-09 22:18:31 +020023BUGS
24 The cast notation only works if the precise type of <value>
25 is known at compile-time. This will not be fixed - use the
26 function form instead.
MG Mud User88f12472016-06-24 23:31:02 +020027
Zesstra715ec202025-07-09 22:18:31 +020028HISTORY
29 Introduced in 3.2.1@2.
30 LDMud 3.2.11/3.3.611 added support for the base prefixes.
31
32SEE ALSO
MG Mud User88f12472016-06-24 23:31:02 +020033 to_string(E), sscanf(E)