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

[bugfix] fix #5596: floating number calculation converter #5597

Closed
wants to merge 2 commits into from

Conversation

Alanscut
Copy link
Contributor

Changes:

@Alanscut Alanscut changed the title [Bugfix] fix #5596: floating number calculation converter [bugfix] fix #5596: floating number calculation converter Jun 14, 2020
@coveralls
Copy link

coveralls commented Jun 14, 2020

Coverage Status

Coverage decreased (-0.09%) to 88.437% when pulling d48376e on Alanscut:issue-5596 into 528ac2b on moment:develop.

@ichernev
Copy link
Contributor

Merged in b4e0676

@ichernev ichernev closed this Dec 23, 2023
ichernev added a commit that referenced this pull request Dec 23, 2023
[bugfix] fix #5596: floating number calculation converter
@ichernev
Copy link
Contributor

I tweaked the original comment a bit. This multiply code basically makes the multiply a tad less wrong, if that.

ichernev added a commit that referenced this pull request Dec 26, 2023
This reverts commit b4e0676, reversing
changes made to cbcd0c5.
@ichernev
Copy link
Contributor

Reverted in 15b82f5

The floating point issues have been notice a while ago, and all this does is revert to the old code (36e5 instead of 1000 * 60 * 60). There is common knowledge that while floating point ops are not perfect, a single op (A * B in this case) is as accurate as possible. This code tries to "improve" the accuracy of simple multiplication (via the newly added multiply fn). However, this is just not possible.

In general the way to "solve" such issues is to compute a complex expression in different order (i.e reorder computations). However there isn't much that can be done in this case.

Read more about it here: #2978

If you just want to convert hours to milliseconds, the formula is hours * 36e5 == ms, and you can round that however way you like (i.e Math.round), chances are that fractional milliseconds are not that useful. But moment can't really make such decisions.

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

Successfully merging this pull request may close these issues.

None yet

3 participants