Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

[VERIFIED] number_to_precision rounding error

#2071

number_with_precision( 32.675, :prescision => 2 ) outputs "32,67" and not "32,68" as expected.

number_with_precision( 31.675, :prescision => 2 ) outputs "31,68" as expected.

This occurred in Rails 2.2.2

Reported by Arndt Touby · February 25th, 2009 @ 02:57 PM

State: resolved
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag set to 2.2.2, bug, bugmash, error

    August 5th, 2009 @ 02:07 PM

  2. Rizwan Reza
    Rizwan Reza
    • Tag changed from 2.2.2, bug, bugmash, error to 2.2.2, 2.3.x, bug, bugmash, error

    verified

    +1 This bug is present in 2.3.3 as well.

    August 7th, 2009 @ 08:57 PM

  3. anupom syam
    anupom syam
    1. seems like this is an issue with Ruby.
    irb(main):080:0> 3267.5.round
    => 3268
    irb(main):081:0> (32.675 * 100.00)
    => 3267.5
    irb(main):082:0> (32.675 * 100.00).round
    => 3267
    irb(main):083:0> 3267.5.round
    => 3268
    

    August 7th, 2009 @ 09:40 PM

  4. anupom syam
    anupom syam

    by the way I meant +1 :P

    August 7th, 2009 @ 09:41 PM

  5. Wesley Moxam
    Wesley Moxam

    I've attached a patch containing a test and a fix.

    August 7th, 2009 @ 10:53 PM

  6. Dan Pickett
  7. Ryan Bigg
    Ryan Bigg

    +1 Patch applies cleanly and all tests pass

    August 8th, 2009 @ 12:55 AM

  8. Ryan Bigg
    Ryan Bigg
    • Title changed from number_to_precision rounding error to [VERIFIED] number_to_precision rounding error

    August 8th, 2009 @ 12:55 AM

  9. Repository
    Repository
    • State changed from new to resolved

    (from [98450fd168673c6bc698b3b2d3c264a9cd70a464]) Fix number_to_precision rounding error [#2071 state:resolved]

    Signed-off-by: Pratik Naik pratiknaik@gmail.com
    http://github.com/rails/rails/commit/98450fd168673c6bc698b3b2d3c264...

    August 8th, 2009 @ 02:08 AM

  10. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from 2.2.2, 2.3.x, bug, bugmash, error to 2.2.2, 2.3.x, bug, error
    • Milestone cleared.

    August 8th, 2009 @ 11:07 PM