STAR - Another one
4 posters
Page 1 of 1
STAR - Another one
This is a snippet
for(double r=0.0;r!=1.0;r+=0.1)printf("*");
How many * will be printed.
And Why???
for(double r=0.0;r!=1.0;r+=0.1)printf("*");
How many * will be printed.
And Why???
SwitchCase- Posts : 5
Join date : 2008-08-13
Re: STAR - Another one
check out this......
u will understand....
float a=3.4;
float b=3.5;
if(a==3.4)
cout<<"hi1";
else
cout<<"bye1";
if(b==3.5)
cout<<"hi2";
else
cout<<"bye2";
u will understand....
float a=3.4;
float b=3.5;
if(a==3.4)
cout<<"hi1";
else
cout<<"bye1";
if(b==3.5)
cout<<"hi2";
else
cout<<"bye2";
Rahul Agrawal- Posts : 3
Join date : 2008-08-13
Re: STAR - Another one
ohh..ans of ur que is infinite..........
Rahul Agrawal- Posts : 3
Join date : 2008-08-13
@rahul
infinite to hai but kyu???
are hum use 0.1 time increase kr rahe hai usme kuch panga hai
because even after becoming 1 r !=1.0 but if we increase r by 1 then it works fine
are hum use 0.1 time increase kr rahe hai usme kuch panga hai
because even after becoming 1 r !=1.0 but if we increase r by 1 then it works fine
mnnit.rahul- Posts : 16
Join date : 2008-08-10
Re: STAR - Another one
Floating-point decimal values generally do not have an exact binary representation. This is a side effect of how the CPU represents floating point data. Different compilers and CPU architectures store temporary results at different precisions, so results will differ depending on the details of your environment. If you do a calculation and then compare the results against some expected value it is highly unlikely that you will get exactly the result you intended.
shivang- Posts : 22
Join date : 2008-08-11
Age : 35
Location : Tondon 174
@shivang
if this is the case the
double t=1.0
if(t==1.0)
cout<<"yes";
else
cout<<"no";
this should gi\ve the answer NO
but instead it i giving YES
moreover if we increase the duoblevalue by 1 it works fine but problem came when we increase it by 0.1
double t=1.0
if(t==1.0)
cout<<"yes";
else
cout<<"no";
this should gi\ve the answer NO
but instead it i giving YES
moreover if we increase the duoblevalue by 1 it works fine but problem came when we increase it by 0.1
mnnit.rahul- Posts : 16
Join date : 2008-08-10
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum