Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

Using broken toFixed() function #378

Open
n9 opened this issue Jan 28, 2015 · 0 comments
Open

Using broken toFixed() function #378

n9 opened this issue Jan 28, 2015 · 0 comments

Comments

@n9
Copy link

n9 commented Jan 28, 2015

JavaScript function toFixed() is "broken". The rounding is not always predictable, for instance:

0.615.toFixed(2) returns "0.61" (because of binary representation)

In Saltarelle, toFixed() is used in ss.netFormatNumber():

Saltarelle: 0.615.ToString("n2") returns "0,61"
.NET: 0.615.ToString("n2") returns "0,62"

An example for a workaround is here: https://github.com/openexchangerates/accounting.js/blob/master/accounting.js#L216

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants