mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
add function to convert numbers to string
This commit is contained in:
parent
bdb5c8e728
commit
c1799616c7
@ -122,6 +122,7 @@ PREP(moveToTempGroup);
|
||||
PREP(muteUnit);
|
||||
PREP(numberToDigits);
|
||||
PREP(numberToDigitsString);
|
||||
PREP(numberToString);
|
||||
PREP(onAnswerRequest);
|
||||
PREP(onLoadRscDisplayChannel);
|
||||
PREP(owned);
|
||||
|
23
addons/common/functions/fnc_numberToString.sqf
Normal file
23
addons/common/functions/fnc_numberToString.sqf
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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"
|
||||
|
||||
private ["_number", "_decimals"];
|
||||
|
||||
_number = _this select 0;
|
||||
|
||||
_decimals = str (_number mod 1);
|
||||
|
||||
_decimals = toArray _decimals;
|
||||
_decimals deleteRange [0,2];
|
||||
|
||||
format ["%1.%2", floor _number, toString _decimals];
|
Loading…
Reference in New Issue
Block a user