Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix and deprecate floatToString #887

Merged
merged 1 commit into from
Feb 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"};