On 2012-04-24 22:13:11 +1200, Michael Kerrisk (man-pages) wrote:
> Vincent,
> 
> On Thu, Jan 6, 2011 at 5:38 AM, Vincent Lefevre <vinc...@vinc17.net> wrote:
> > The isgreater(3) man page says:
> >
> >  The  normal  relation operations (like <, "less than") will fail if one
> >  of the operands is NaN.  This will cause an exception.  To avoid  this,
> >  C99  defines these macros.  The macros are guaranteed to evaluate their
> >  operands only once.  The operands can be  of  any  real  floating-point
> >  type.
> >
> > It should probably be emphasised that the operands must not be of
> > integer types.
> 
> The man page already says: "The operands can be of any real
> floating-point type." Is that not emphasis enough?

This is a bit ambiguous, as "can" is not necessarily exclusive.
Macros often have a function-like interface: for instance, if a
real floating-point type is expected and the user provides an
integer, then the integer will automatically be converted to a
real floating-point type. This is not the case here.

Also, the beginning of the paragraph is a bit like saying that
"isgreater" is a safe replacement for ">" to avoid a possible
exception. However, while with ">" the user doesn't need to take
care of the types, this is not the case for "isgreater". For
instance, in order to avoid a possible exception, one should
do the following replacements:

With

  double x
  int i;

replace

  x > i
  x > 0

by

  isgreater (x, (double) i)
  isgreater (x, 0.0)

Users may easily forget to do the change on the second argument.

-- 
Vincent Lefèvre <vinc...@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to