Skip to content

Commit

Permalink
fix and deprecate floatToString (#887)
Browse files Browse the repository at this point in the history
  • Loading branch information
commy2 authored Feb 13, 2018
1 parent e5b4803 commit 225d983
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion addons/main/script_macros_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion addons/strings/fnc_floatToString.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* -----------------------------------------------------------------------------
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.
Expand All @@ -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"};

0 comments on commit 225d983

Please sign in to comment.