wat's the o/p of pgm??
2 posters
wat's the o/p of pgm??
float f=5.5;
double d=5.5;
if(f==d)
cout<<"Equal";
else
cout<<"Not equal";
i get not equal as o/p..
y is it so?
double d=5.5;
if(f==d)
cout<<"Equal";
else
cout<<"Not equal";
i get not equal as o/p..
y is it so?
Naveen- Posts : 15
Points : 21
Join date : 2010-03-05
Age : 35
Re: wat's the o/p of pgm??
r u asking in java or c++??? In c++, it is equal. But java is strongly typed language, so float and double are different. I think thaty u r getting not equal. not sure. ll give a try.
Re: wat's the o/p of pgm??
Hey even in c++ i do get the sam o/p...
u jus check it out...
u jus check it out...
Naveen- Posts : 15
Points : 21
Join date : 2010-03-05
Age : 35
Re: wat's the o/p of pgm??
i tried it. it s working fine. anyways it depends on the compiler we use. which compiler r u using??
Re: wat's the o/p of pgm??
Dev... wat compiler do u use?
Naveen- Posts : 15
Points : 21
Join date : 2010-03-05
Age : 35
Re: wat's the o/p of pgm??
check ur pgm. the following stmt ll throw u error when u try to compile it.
by default decimal values are double in java. so if u want to initialize a float variable, u have to type cast it.
- Code:
float f=5.5
by default decimal values are double in java. so if u want to initialize a float variable, u have to type cast it.
- Code:
float f=5.5f;
or
float f=5.5F;
or
float f=(float)5.5;
Permissions in this forum:
You cannot reply to topics in this forum
|
|