ACE3/addons/common/functions/fnc_numberToString.sqf

26 lines
520 B
Plaintext
Raw Normal View History

/*
* Author: commy2
*
* Converts a number to a string without losing as much precission as str or format.
*
* Argument:
* 0: A number (Number)
*
* Return value:
* The number as string (String)
*/
#include "script_component.hpp"
2015-05-14 18:06:06 +00:00
private ["_decimals"];
2015-05-14 18:06:06 +00:00
PARAMS_1(_number);
2015-04-06 19:12:38 +00:00
_decimals = str (abs(_number) mod 1);
_decimals = toArray _decimals;
2015-04-06 19:12:38 +00:00
_decimals deleteAt 0;
2015-04-06 19:12:38 +00:00
if (_number < 0) exitWith {
format ["-%1%2", floor abs(_number), toString _decimals];
};
format ["%1%2", floor _number, toString _decimals];