P
Pietro Cerutti
Hi group,
I always thought that applying a binary operator such as ==, !=, <= or
Now, I'm passing a program through splint[1] and it says:
Dangerous equality comparison involving double types:
l_lnk1->lnk_freq == l_lnk2->lnk_freq
Two real (float, double, or long double) values are compared directly
using == or != primitive. This may produce unexpected results since
floating point representations are inexact. Instead, compare the
difference to FLT_EPSILON or DBL_EPSILON.
l_lnk1->lnk_freq and l_lnk2->lnk_freq being defined as double values.
Is it really better to write the comparison as
(l_lnk1->lnk_freq - l_lnk2->lnk_freq < DBL_EPSILON)
or is splint being over-pedantic in this situation?
Thank you!
[1] http://www.splint.org/
I always thought that applying a binary operator such as ==, !=, <= or
well defined.= to two double or float values was an operation which results were
Now, I'm passing a program through splint[1] and it says:
Dangerous equality comparison involving double types:
l_lnk1->lnk_freq == l_lnk2->lnk_freq
Two real (float, double, or long double) values are compared directly
using == or != primitive. This may produce unexpected results since
floating point representations are inexact. Instead, compare the
difference to FLT_EPSILON or DBL_EPSILON.
l_lnk1->lnk_freq and l_lnk2->lnk_freq being defined as double values.
Is it really better to write the comparison as
(l_lnk1->lnk_freq - l_lnk2->lnk_freq < DBL_EPSILON)
or is splint being over-pedantic in this situation?
Thank you!
[1] http://www.splint.org/