+ 4

Why 0.1 + 0.2 == 0.3 is false ??

Why 0.1 + 0.2 == 0.3 is false ?? https://code.sololearn.com/cn9WNbcA788W/?ref=app

21st Sep 2019, 3:57 PM
DÄRK PRÌÑÇÉ [ Inactive ]
DÄRK PRÌÑÇÉ [ Inactive ] - avatar
4 Answers
+ 6
Because double has 15 decimal digits of precision means: a=0.1;//0.100000000000001 b=0.2;//0.200000000000003 c=0.3;//0.300000000000004 But in float data type floating point is not change. change data type double to float
21st Sep 2019, 4:44 PM
Prathvi
Prathvi - avatar
+ 1
Hello World and burey thanks i got the answer
21st Sep 2019, 5:42 PM
DÄRK PRÌÑÇÉ [ Inactive ]
DÄRK PRÌÑÇÉ [ Inactive ] - avatar
0
Because floating point arithmetic is not exact due to the representation of floats in computers not being exact.
22nd Sep 2019, 9:46 PM
Sonic
Sonic - avatar