c - why is if(1/10) and if(0.1) have different values? -
this question has answer here:
- what behavior of integer division? 5 answers
just not understand why following 2 have different values. first 1 has value 0, while other has value 1
if(1/10); if(0.1);
by default type of 1
int
, 1/10
rounded down 0
equivalent false
. while 0.1
has bits set , not 0
.
on other hand 1.0/10
equivalent 0.1
.
Comments
Post a Comment