+ 1
What the answer is not equal here?
float f1 = 0.1; if(f1 == 0.1) printf("Equal"); else printf("Not equal"); O/P :- Not equal
5 Answers
+ 2
Because floating point numbers have certain accuracy. Double type is more precise than float type. Please look at the code. Hope it helps you đ
https://code.sololearn.com/c3S3k9To6R0D/?ref=app
+ 1
Because in you need to write "if(f1 == 0.1f)". because the "f" tells the compiler to use the number as a float instead of a double.
+ 1
Thanks to all of you guys
One more question
What will store if we store 0.1 in float ? Means will it store as 0.1 or as 0.100...?
+ 1
Suraj Patra 0.100..., because of accuracy of the representation.
+ 1
Thanks