bug-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gsl] GSL_NEGZERO


From: Gerard Jungman
Subject: Re: [Bug-gsl] GSL_NEGZERO
Date: Thu, 14 Apr 2011 15:40:35 -0600

On Thu, 2011-04-14 at 13:44 +0100, Brian Gough wrote:
> 
> Hi. Apparently floating point constants require a "." as in
> LESS_GENERIC_NEGZERO.  Integer constants don't include the -, so
> GENERIC_NEGZERO is unary minus on integer 0 => integer zero.  Promoted
> to double after that, so +0.0.

Yeah, it's logical. Just somewhat surprising.

I noticed that the following is assigned without warning (-Wall):

  #define LESS_GENERIC_NEGZERO (-0.0)
  int okthen = LESS_GENERIC_NEGZERO;

So it is tempting to decide that (-0.0) is ok for both floating
point and integer contexts. But that creeps me out.

Also, the following compiles without warning:

  double w = -0.0;
  int okmaybe = w;


Back to my semi-original question: Why is neg-zero a macro instead
of a floating-point constant?






reply via email to

[Prev in Thread] Current Thread [Next in Thread]