From fee532a9777d316e30f5a88af64ff6f74ac0e3d2 Mon Sep 17 00:00:00 2001 From: commy2 Date: Tue, 13 Feb 2018 12:40:46 +0100 Subject: [PATCH] fix and deprecate floatToString --- addons/main/script_macros_common.hpp | 2 +- addons/strings/fnc_floatToString.sqf | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/main/script_macros_common.hpp b/addons/main/script_macros_common.hpp index ef17ca1d4..4a5c7a76d 100644 --- a/addons/main/script_macros_common.hpp +++ b/addons/main/script_macros_common.hpp @@ -1081,7 +1081,7 @@ Macros: IS_x() #define IS_INTEGER(VAR) (if (IS_SCALAR(VAR)) then {floor (VAR) == (VAR)} else {false}) #define IS_NUMBER(VAR) IS_SCALAR(VAR) -#define FLOAT_TO_STRING(num) (str parseNumber (str (_this%_this) + str floor abs _this) + "." + (str (abs _this-floor abs _this) select [2]) + "0") +#define FLOAT_TO_STRING(num) (if (_this == 0) then {"0"} else {str parseNumber (str (_this % _this) + str floor abs _this) + "." + (str (abs _this - floor abs _this) select [2]) + "0"}) /* ------------------------------------------- Macro: SCRIPT() diff --git a/addons/strings/fnc_floatToString.sqf b/addons/strings/fnc_floatToString.sqf index 3cc76ad9a..adb55f029 100644 --- a/addons/strings/fnc_floatToString.sqf +++ b/addons/strings/fnc_floatToString.sqf @@ -1,6 +1,8 @@ /* ----------------------------------------------------------------------------- Function: CBA_fnc_floatToString +DEPRECATED - Please use added in Arma 3 1.66 + Description: Returns a higher precision string representation of a IEEE 754 floating point number than the str function. @@ -27,4 +29,4 @@ Author: Nou ---------------------------------------------------------------------------- */ -str parseNumber (str (_this % _this) + str floor abs _this) + "." + (str (abs _this - floor abs _this) select [2]) + "0"; +if (_this == 0) then {"0"} else {str parseNumber (str (_this % _this) + str floor abs _this) + "." + (str (abs _this - floor abs _this) select [2]) + "0"};