From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.gentoo.org ([140.105.134.102] helo=robin.gentoo.org) by nuthatch.gentoo.org with esmtp (Exim 4.50) id 1EV8hg-00072z-TO for garchives@archives.gentoo.org; Thu, 27 Oct 2005 14:26:05 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.13.5/8.13.5) with SMTP id j9REP0Hq010533; Thu, 27 Oct 2005 14:25:00 GMT Received: from smtp.inesc-id.pt (smtp.inesc-id.pt [146.193.32.2]) by robin.gentoo.org (8.13.5/8.13.5) with ESMTP id j9REP0kZ008219 for ; Thu, 27 Oct 2005 14:25:00 GMT Received: from joana.inesc-id.pt (joana.inesc-id.pt [146.193.57.4]) by smtp.inesc-id.pt (8.13.1/8.13.1/SuSE Linux 0.7) with ESMTP id j9REOsvQ032222 for ; Thu, 27 Oct 2005 15:24:54 +0100 From: Miguel Barao Organization: INESC-ID Lisboa To: gentoo-science@lists.gentoo.org Subject: Re: [gentoo-science] question about signbit Date: Thu, 27 Oct 2005 15:24:54 +0100 User-Agent: KMail/1.8.1 References: <200510221416.03348.dd55@cornell.edu> <435AA97C.7020103@gmx.net> <200510270852.35524.dd55@cornell.edu> In-Reply-To: <200510270852.35524.dd55@cornell.edu> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-science@gentoo.org Reply-to: gentoo-science@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200510271524.54132.mjsb@ramses.inesc-id.pt> X-Virus-Scanned: by amavisd-new X-Archives-Salt: 5626f315-0d73-44d4-89c4-4b3e980fbf20 X-Archives-Hash: 75b0df7ba1fcf89822b79227cc30b4b8 On Thursday 27 October 2005 13:52, Darren Dale wrote: > > Here is another test: > > #include > #include > > 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@gentoo.org mailing list