Float#round doesn't return nearest integers in some cases
---------------------------------------------------------

                 Key: JRUBY-5048
                 URL: http://jira.codehaus.org/browse/JRUBY-5048
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.5.2
         Environment: Ubuntu 10.04
            Reporter: Shugo Maeda
            Priority: Minor
         Attachments: float-round.diff

Float#round doesn't return nearest integers, for example in the following case:

{noformat}
$ ruby1.8 -v -e 'p 0.49999999999999994.round'
ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]
0
$ jruby1.5 -v -e 'p 0.49999999999999994.round'
jruby 1.5.2 (ruby 1.8.7 patchlevel 249) (2010-08-20 1c5e29d) (Java HotSpot(TM) 
Client VM 1.6.0_20) [i386-java]
1
$ 
{noformat}

That is caused by the rounding error of 0.49999999999999994 + 0.5.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to