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:   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)

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

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.

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

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

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?

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

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

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.


Post your comments here:

Your comments will be displayed after verification.