www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: float equality

reply Kagamin <spam here.lot> writes:
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?
Feb 21 2011
parent "Robert Jacques" <sandford jhu.edu> writes:
On Mon, 21 Feb 2011 10:15:28 -0500, Kagamin <spam here.lot> wrote:

 bearophile Wrote:

 Jonathan M Davis:

 The thing is, of course, that actual equality sucks for floating  

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.
Feb 21 2011