could somebody explain why the following code gives "invalid" as the output?

// code

float w=2.3;
if(w==2.3)
puts("valid");
else
puts("invalid");

//********

when I tried the same with double datatype, it worked!!!
It also worked when I changed the if statement to

if(w==2.3f)
puts("valid");
else
puts("invalid");