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

Bug in Genghis.Util.humanizeSize #167

Closed
thomas-riccardi opened this Issue Mar 20, 2014 · 3 comments

Comments

Projects
None yet
2 participants
@thomas-riccardi
Genghis.Util.humanizeSize(144.05351170568562)
// result: '1445 Bytes'

I found this in the 'Avg. object size' in some collections.

Why is Genghis.Util.round so complicated?

@bobthecow bobthecow closed this in f31c740 Mar 20, 2014

@bobthecow

This comment has been minimized.

Show comment
Hide comment
@bobthecow

bobthecow Mar 20, 2014

Owner

Thank you for reporting this. It has been fixed in v2.3.11.

Genghis.Util.round is so complicated because it's poorly named and has to deal with a lot of edge cases :)

The bug was in humanizeSize, though.

size = Genghis.Util.round(size, 2).toString().replace(/\.0+/, '');

That regex is missing an anchor, so it removes the .0 in 144.05 and ends up with 1445.

Owner

bobthecow commented Mar 20, 2014

Thank you for reporting this. It has been fixed in v2.3.11.

Genghis.Util.round is so complicated because it's poorly named and has to deal with a lot of edge cases :)

The bug was in humanizeSize, though.

size = Genghis.Util.round(size, 2).toString().replace(/\.0+/, '');

That regex is missing an anchor, so it removes the .0 in 144.05 and ends up with 1445.

@thomas-riccardi

This comment has been minimized.

Show comment
Hide comment
@thomas-riccardi

thomas-riccardi Mar 20, 2014

Thanks for the quick fix!

Thanks for the quick fix!

@bobthecow

This comment has been minimized.

Show comment
Hide comment
@bobthecow

bobthecow Mar 20, 2014

Owner

No problem.

Owner

bobthecow commented Mar 20, 2014

No problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment