Re: 0.1 = 0 ???
From: Jumbo ((nospam)_at_12freeukisp.co.uk)
Date: 10/26/03
- Previous message: Paul F. Johnson: "g++ and VC++ (off topic?)"
- In reply to: Paul Surgeon: "0.1 = 0 ???"
- Next in thread: Anand Hariharan: "Re: 0.1 = 0 ???"
- Reply: Anand Hariharan: "Re: 0.1 = 0 ???"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 :-)
- Previous message: Paul F. Johnson: "g++ and VC++ (off topic?)"
- In reply to: Paul Surgeon: "0.1 = 0 ???"
- Next in thread: Anand Hariharan: "Re: 0.1 = 0 ???"
- Reply: Anand Hariharan: "Re: 0.1 = 0 ???"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|