C Programming - Floating Point Issues - Discussion

Discussion Forum : Floating Point Issues - General Questions (Q.No. 1)
1.
What are the different types of real data type in C ?
float, double
short int, double, long int
float, double, long double
double, long int, float
Answer: Option
Explanation:
The floating point data types are called real data types. Hence float, double, and long double are real data types.
Discussion:
17 comments Page 2 of 2.

Sivakumar said:   1 decade ago
int main(){
float x;
x=(float)3.3==3.3;
printf("%f",x);
return 0;
}

Ans 0.00


int main(){
float x;
x=(float)3.5==3.5;
printf("%f",x);
return 0;
}

Ans 1.00

How it is possible please anyone could you explain please?

Akshay said:   1 decade ago
#include<stdio.h>
int main(){
float x;
x=(float)4.2==(float)4.2;
printf("%f",x);

x=(float)3.5==3.5;
printf("\n%f",x);
return 0;
}

Answer:

1.00
1.00

This one works. I just converted both no into float.

I just cannot figure out exactly why this is happening. Hope someone can figure out.

V.koks said:   1 decade ago
How the output came like this?

Sachin said:   1 decade ago
Anyone could explain me how this code has worked?

Anusha said:   1 decade ago
I do not exactly. But I think this concept follows partial initialization, full initialization, null initialization. If I'm wrong any explain me the concept.

Mustaqueem khan said:   1 decade ago
Very good example given by all of you. Thanks for your time.

Akshay said:   8 years ago
@Akshay.

Just use like Logical Operators (float)4.2==(float)4.2 is equal, so that's true and prints 1, as float, 1.0000000.
(1)


Post your comments here:

Your comments will be displayed after verification.