emcien/number-helpers-coffeescript — pull request #3 by scpike (2014-02-28 03:14:35+00:00)
Title: Numbers > 0.50 should round up

In your spec, you have this expected to be '$1,234,567,890':

NumberHelpers.number_to_currency(1234567890.506, {precision: 0});

Rails does this (IMO more sensible rounding):

> number_to_currency(1234567890.506, precision: 0)
=> "$1,234,567,891"

The rounding of .50 up or down is a matter of opinion, but this is certainly a bug:

NumberHelpers.number_to_currency(2.999, {precision: 2});

=> $2.00

And even this:

NumberHelpers.number_to_currency(2.99, {precision: 0});

=> $2

This adds more specs and fixes the bug. I also round .506 up because in my
personal usage of this library I want to match Rails's behavior.

Thanks for the library!