forked from CBATeam/CBA_A3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfnc_floatToString.sqf
32 lines (22 loc) · 1.11 KB
/
fnc_floatToString.sqf
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
/* -----------------------------------------------------------------------------
Function: CBA_fnc_floatToString
DEPRECATED - Please use <toFixed at https://community.bistudio.com/wiki/toFixed> added in Arma 3 1.66
Description:
Returns a higher precision string representation of a IEEE 754 floating point
number than the str function.
This function is as barebones as possible. Inline macro version of this
function can be used with FLOAT_TO_STRING(num).
Limitations:
Parameters:
_number - Number to format [Number]
Returns:
The number formatted into a string.
Examples:
(begin example)
_str = 100.12345678 call CBA_fnc_floatToString; // _str = "100.123459", using (str 100.12345678) results in "100.123"
_str = 2000.1236 call CBA_fnc_floatToString; // _str = "2000.1236570", using (str 2000.1236) results in "2000.12"
(end)
Author:
Nou
---------------------------------------------------------------------------- */
if (_this == 0) then {"0"} else {str parseNumber (str (_this % _this) + str floor abs _this) + "." + (str (abs _this - floor abs _this) select [2]) + "0"};