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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -