c - why is if(1/10) and if(0.1) have different values? -


this question has answer here:

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

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -