[#9722] Kernel#system broken inside Dir.chdir(&block) if system command doesn't have shell characters — <noreply@...>

Bugs item #7278, was opened at 2006-12-14 13:59

8 messages 2006/12/14

[#9749] System V IPC in standard library? — Steven Jenkins <steven.jenkins@...>

Back in August, I needed a semaphore to serialize access to an external

14 messages 2006/12/19

[#9753] CVS freeze — SASADA Koichi <ko1@...>

Hi,

20 messages 2006/12/20
[#9755] Re: [ruby-dev:30039] CVS freeze — SASADA Koichi <ko1@...> 2006/12/20

Hi,

[#9757] Re: [ruby-dev:30040] Re: CVS freeze — SASADA Koichi <ko1@...> 2006/12/20

Hi,

Re: Float numbers comparison

From: "Paulo Soeiro" <pcsoeiro@...>
Date: 2006-12-16 19:38:38 UTC
List: ruby-core #9735
Hi,

Thank you all for your awnsers, i haven't read them all. But i don't see
this problem occurring in java language, when comparing 1.9 with 1.8+0.1.
And java, seems to be using the same standard:
http://java.sun.com/docs/books/vmspec/2nd-edition/html/Concepts.doc.html#33377

Thank you very much.
Paulo Soeiro

-------------------

package javaapplication1;

import java.lang.* ;

public class Main {

    public Main() {

    }

    public static void main(String[] args) {
        // TODO code application logic here
        for(int i=0; i<1000; i++){
            float a=(float)1.9;
            float b=(float)1.8+(float)0.1;


           System.out.println(a==b);

           System.out.println("a-b="+(a-b));

        }
   }
}

--
...
true
a-b=0.0
true
a-b=0.0
true
a-b=0.0
true
a-b=0.0
true

...

On 12/2/06, Wilson Bilkovich <wilsonb@gmail.com> wrote:
>
> On 12/1/06, Paulo Soeiro <pcsoeiro@gmail.com> wrote:
> > Hi,
> >
> > I have a doubt about the floating point comparisons:
> >
> > a=1.9
> > b= 1.8 +0.1
> > puts a==b  #false
> >
> > The result is false.
> >
> > If i change the values,
> >
> > a=1.6
> > b= 1.5 +0.1
> > puts a==b  #true
> >
> > The result is true
> >
> > This doesn't seem to happen in C  language or in Java language.
> > Is it a bug? I'm using ruby version 1.8.5.
> >
>
> 0.1 is a repeating series in binary, like 1/3 in decimal. (0.3333333333~)
> Adding small FP values to certain others can have unexpected results.
> Equality is not guaranteed in IEEE floating point.
>
> See here for more info:
> http://en.wikipedia.org/wiki/IEEE_754
>
> This is not specific to Ruby, but basically amounts to the way your
> computer's CPU represents floating-point numbers.
>
>

In This Thread