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 1ETQWf-0006jS-Uq for garchives@archives.gentoo.org; Sat, 22 Oct 2005 21:03:38 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.13.5/8.13.5) with SMTP id j9ML027B025692; Sat, 22 Oct 2005 21:00:02 GMT Received: from mail.gmx.net (mail.gmx.de [213.165.64.20]) by robin.gentoo.org (8.13.5/8.13.5) with SMTP id j9ML01pE031078 for ; Sat, 22 Oct 2005 21:00:01 GMT Received: (qmail invoked by alias); 22 Oct 2005 21:02:44 -0000 Received: from d046119.adsl.hansenet.de (EHLO [192.168.2.189]) [80.171.46.119] by mail.gmx.net (mp001) with SMTP; 22 Oct 2005 23:02:44 +0200 X-Authenticated: #25576946 Message-ID: <435AA97C.7020103@gmx.net> Date: Sat, 22 Oct 2005 23:05:00 +0200 From: Marco Matthies User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051014) X-Accept-Language: en-us, en 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 To: gentoo-science@lists.gentoo.org Subject: Re: [gentoo-science] question about signbit References: <200510221416.03348.dd55@cornell.edu> In-Reply-To: <200510221416.03348.dd55@cornell.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Archives-Salt: c52184fd-a298-48e1-8ad8-91c78fcc2446 X-Archives-Hash: f05fac879503b004b071e6abc6dbd567 Darren Dale wrote: > On my system, SciPy's signbit function reports that the sign bit is not set > for any number, positive or negative. Could someone here help me understand > how to test the libc signbit function? I have to admit I have no experience > with C programming. Hi Darren, the signbit fuction is actually a macro (as the manpage says) defined in math.h that in turn calls the right inline function (for the type needed) which is defined in mathinline.h --- so as far as i can see, libc should not be involved, only header files. I have attached a small example below on how to use the function. Please note the use of -std=c99 (you may also use -std=gnu99) as the macro is only activated when in C99 mode and gcc's default mode is C89 ("ANSI C"). If you're interested in the differences between the two standards the wikipedia entry on c has some info: http://en.wikipedia.org/wiki/C_programming_language the program (save it under signbit_test.c): [cut] #include #include int main() { printf("sign of 1.7 is %d\n", signbit(1.7)); printf("sign of -1.1 is %d\n", signbit(-1.1)); printf("sign of -0.0 is %d\n", signbit(-0.0)); printf("sign of 0.0 is %d\n", signbit(0.0)); return 0; } [/cut] compile with: gcc -Wall -std=c99 -lm signbit_test.c -o signbit_test run with: ./signbit_test should produce this output: sign of 1.7 is 0 sign of -1.1 is -2147483648 sign of -0.0 is -2147483648 sign of 0.0 is 0 This was run with gcc 3.4.4 on amd64, if you want to i can try on a x86 install in qemu. Marco -- gentoo-science@gentoo.org mailing list