MATLAB: If statement different answer when input variable vs number

if statementvariables

I do not understand why the if statement here produces different results. In one statement, I use the variable names, and in the other I substitute the variable values for the names. Each if statement should yield 'true' because no values are changed.
>> time_end
time_end =
30.0000
>> time_met_end
time_met_end =
30
>> if time_end>time_met_end
disp('true')
end
true
>> if 30.0000 > 30
disp('true')
end
>>
>>

Best Answer

See the FAQ Why is 0.3-0.2-0.1 not equal to zero? for background in "why". The variable containing what is printed at the command line as 30.0000 isn't quite that, exactly. That the trailing zeros after the decimal are printed is the giveaway that it isn't integer-valued.
Try
time_end-30
to see the remainder for
fprintf('%.15e',time_end)
to display the value with all the digits shown.