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

Using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors #2995

Closed
wants to merge 2 commits into from

Conversation

afanasy
Copy link
Contributor

@afanasy afanasy commented Mar 1, 2016

@mattjohnsonpint
Copy link
Contributor

Thanks! Could you also include a unit test so we can be sure this doesn't revert with some future change? The example code from the original issue should do fine.

Also, Were you able to find any other cases of this besides just the one reported? Thanks.

@afanasy
Copy link
Contributor Author

afanasy commented Mar 8, 2016

I think there are lots of cases, but I don't know how to summarise the problem in a more analytical way. This is another one I've found by picking numbers manually:

//moment.js 2.11.2
moment.duration(0.1, 'h').minutes()
//6, as expected
moment.duration(4.1, 'h').minutes()
//5
//?!?

but this PR fixes it

@mattjohnsonpint
Copy link
Contributor

Thanks. We'll merge this in the next release. I suppose we'll have to tackle this one report at a time.

@ichernev
Copy link
Contributor

Merged in 544a059

@ichernev ichernev closed this Apr 16, 2016
ichernev added a commit that referenced this pull request Apr 16, 2016
Using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants