Re: 0.1 = 0 ???

From: Jumbo ((nospam)_at_12freeukisp.co.uk)
Date: 10/26/03

  • Next message: Martin Henne: "Re: [C++] std::ostream::rdbuf()"
    Date: Sun, 26 Oct 2003 14:06:44 -0000
    
    

    "Paul Surgeon" <surgptr@pop.co.za> wrote in message
    news:bnghgu$3gt$1@ctb-nnrp2.saix.net...
    > I cannot figure out how C++ works with data types/conversions.
    > I have tried two conditional statements :
    >
    > if ((1 / 10) == 0)
    > cout << "Houston we have a problem\n";
    >
    >
    > double Data = (1 / 10);
    > if (Data == 0)
    > cout << "Houston we have a problem\n";
    >
    > In both cases the conditional statement resolves as true!
    > How the *beep* can 0.1 be equal to 0?
    >
    > What on earth am I doing wrong?
    >
    > I have never seen this problem in my 4 years of Delphi coding.
    > What is C++ doing that is so different?
    >
    > Thanks
    > Paul
    >

    This works :
    float data=1;
    data /=10;
    if(data==0)
    cout<<"Houston we have a problem!";

    LOL
    I think it's because its getting rounded down,
    I know it's drives you crazy and it has driven me crazy on numerous
    occassions too .- LOL

    good luck :-)


  • Next message: Martin Henne: "Re: [C++] std::ostream::rdbuf()"

    Relevant Pages

    • Re: 0.1 = 0 ???
      ... > I have tried two conditional statements: ... > What on earth am I doing wrong? ... > I have never seen this problem in my 4 years of Delphi coding. ... You are dividing integers and expecting a decimal result. ...
      (alt.comp.lang.learn.c-cpp)
    • 0.1 = 0 ???
      ... I cannot figure out how C++ works with data types/conversions. ... I have tried two conditional statements: ... What on earth am I doing wrong? ... I have never seen this problem in my 4 years of Delphi coding. ...
      (alt.comp.lang.learn.c-cpp)