float equality

Robert Jacques sandford at jhu.edu
Mon Feb 21 08:06:40 PST 2011


On Mon, 21 Feb 2011 10:15:28 -0500, Kagamin <spam at here.lot> wrote:

> bearophile Wrote:
>
>> Jonathan M Davis:
>>
>> > The thing is, of course, that actual equality sucks for floating  
>> point values.
>>
>> So much, that some people have proposed to deprecate the normal FP  
>> equality. MISRA-C disallows them. When you see a == among FP values is  
>> often a code smell.
>>
>
> Is it safe to assert that noone needs exact FP comparison?

Nope. if(var == 0) is a common, important and valid test. To say nothing  
of testing for sentinel values.


More information about the Digitalmars-d mailing list