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 1 of 2.

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.

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?

Ajay said:   1 decade ago
float, double and long double called real data type because it's compute real value of any number. For Example if we want to get accurate output suppose A = 2.3 and B = 3.2 and C, Thus, C = A +B;

We get 5.500000; Hence its called a real data type.

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.

Smiline jeba said:   1 decade ago
Because it gives the real value. Ex 2/5=2.50 it is the real value. It calculate the value accurately. If am wrong. Please correct me.

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)

Shiv gauri said:   1 decade ago
The floating point data types are called real data types. Hence float, double, and long double are real data types.

Ajay said:   1 decade ago
Could you explain me what is deference between double and long double real data type?

Safi said:   1 decade ago
A real data type is float. Therefor float, double, long double re real data types.

Thomsika said:   1 decade ago
Can you explain the difference between float, double and long double?


Post your comments here:

Your comments will be displayed after verification.