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

CBA_fnc_formatNumber returns bad values in some cases #486

Closed
Sniperhid opened this issue Aug 25, 2016 · 4 comments
Closed

CBA_fnc_formatNumber returns bad values in some cases #486

Sniperhid opened this issue Aug 25, 2016 · 4 comments
Labels
Milestone

Comments

@Sniperhid
Copy link
Contributor

Arma 3 Version: 1.62 (stable)
CBA Version: 3.0.0 (stable)

Mods:

  • @CBA_A3

Description:
With some inputs CBA_fnc_formatNumber will not behave as expected.

Steps to reproduce:
In debug console variable watch put -> [65.200, 2, 3] call CBA_fnc_formatNumber

Observed result: "65.299"

Expected result: "65.200"

@PabstMirror
Copy link
Contributor

Joys of floating points

(65.2 * 10^2) % 10 = 9.99951
(65.2 * 100) % 10 = 9.99951
(65.2 * 10 * 10) % 1 = 0

@jokoho48
Copy link
Member

https://www.youtube.com/watch?v=PZRI1IfStY0
if you want to know why this happend :)

@shadez95
Copy link
Contributor

Probably best to avoid floating points whenever you can.

@commy2
Copy link
Contributor

commy2 commented Aug 31, 2016

Question is: can we improve CBA_fnc_formatNumber to be as precise as possible with all SQF tricks or is it already as good as it gets?

@commy2 commy2 closed this as completed Sep 6, 2016
@commy2 commy2 modified the milestones: 3.0, 3.1 Sep 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants