MATLAB: Why this logical expression is wrong

accuracy problemfloating pointlogical?MATLAB

Hi,
why this statment is wrong,
>> sind(30)==0.5
ans =
0

Best Answer

because of the accuracy problem of a floating-point system
>> format longE
>> sind(30)
ans =
4.999999999999999e-01
Never, ever compare two floating-point numbers with == operand!
See also: