Gentoo Archives: gentoo-science

From: Miguel Barao <mjsb@×××××××××××××××.pt>
To: gentoo-science@l.g.o
Subject: Re: [gentoo-science] question about signbit
Date: Thu, 27 Oct 2005 14:26:05
Message-Id: 200510271524.54132.mjsb@ramses.inesc-id.pt
In Reply to: Re: [gentoo-science] question about signbit by Darren Dale
On Thursday 27 October 2005 13:52, Darren Dale wrote:
> > Here is another test: > > #include <math.h> > #include <stdio.h> > > int main() { > printf("signbit(-1): %d\n", signbit(-1)); > printf("isnan(0.0/0): %d\n", isnan(0.0/0)); > printf("isinf(1.0/0): %d\n", isinf(1.0/0)); > return 0; > } > > which yields: > > signbit(-1): -2147483648 > isnan(0.0/0): 1 > isinf(1.0/0): 1 > > Do you know why signbit doesn't yield 1?
The answer is in 'man signbit'. signbit is probably just ANDing your float value with 2^31=0x80000000 which reads -2147483648 if considered as a signed int (like in your printf). Miguel -- gentoo-science@g.o mailing list

Replies

Subject Author
Re: [gentoo-science] question about signbit Ertugrul Soeylemez <never@××××××××××.org>