logo       

Re: signbit ISO C99 macro: msg#00005

Subject: Re: signbit ISO C99 macro
On Mon, May 13, 2002 at 11:13:58AM -0700, Bill Fenner wrote:
> 
> It's easy if it's easy to treat doubles as uint64_t's.  Like, I think
> signbit() might be something like
> 
> #define       signbit(d)      (*((uint64_t *)&(d)) & 
> UINT64_C(0x8000000000000000))
> 
> or maybe
> 
> #define       signbit(d)      (*((uint64_t *)&(d)) >> 63)
> 
> However, that assumes that d is an IEEE double (and there is a
> possibly-incorrect assumption about byte order).  I don't know how to
> implement a macro that will take any real-floating type.

signbit isn't limited to lvalues, is it?  You'll have to handle eg
signbit(3.0) too.

Stefan Farfeleder

To Unsubscribe: send mail to majordomo@xxxxxxxxxxx
with "unsubscribe freebsd-standards" in the body of the message



<Prev in Thread] Current Thread [Next in Thread>