Paul Eggert wrote:
> It is referring to the behavior of the VAX floating point unit, where the
> hardware representation that one thinks would represent -0.0 behaves
> sort of like a NaN. To avoid this problem, on a VAX copysign(0, -1)
> returns +0.0, not the usual -0.0. That is why the C and POS
Bruno Haible <[EMAIL PROTECTED]> writes:
> In other words, the standard allows the function to be buggy...
The wording you quoted is talking about something else. It is
referring to the behavior of the VAX floating point unit, where the
hardware representation that one thinks would represent -0.
Paul Eggert wrote:
> vasnprintf.c should do this:
>
> if (copysignl (1, arg) < 0)
> {
> sign = -1;
> arg = -arg;
> }
>
> I think it's much cleaner. And the code is smaller on my platform,
> anyway: no function call is generated for copysignl.
The "right" way to test for -0 versus +0 is to use copysign.
For example, instead of this:
if (arg < 0.0L)
{
sign = -1;
arg = -arg;
}
else if (arg == 0.0L)
{
/* Distinguish 0.0L and -0.0L. */
static long
Clarification:
> > - On Alpha processors, division by zero (and even overflow!) leads to a
> > SIGFPE
> > signal by default. And it requires the use of a system call to change
> > the FP exceptions control mask (the routines in glibc >= 2.1,
> > the __setfpucw function in glibc 2.0
Eric Blake wrote:
> recent coreutils snapshots have used it, and no one has complained so far.
Plenty of packages have used it for 10 years or longer: GCC installs or
installed files in $prefix/include/g++, and a library called libstdc++.
binutils has a program called 'c++filt'. gettext is using a
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
According to Bruno Haible on 3/24/2007 7:04 PM:
>
> 2007-03-24 Bruno Haible <[EMAIL PROTECTED]>
>
> * lib/float+.h: New file.
Is + a reasonable file name character these days? On the one hand, it is
not listed in the "portable filename char
Eric Blake <[EMAIL PROTECTED]> writes:
> According to Bruno Haible on 3/25/2007 9:57 AM:
>> Eric Blake wrote:
>>> /* return true iff the representation of d needs a leading '-' */
>>> bool
>>> is_negative (long double d)
>>> {
>>> if (d == 0)
>>> {
>>> union {
>>> long double d
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
According to Bruno Haible on 3/25/2007 9:57 AM:
> Eric Blake wrote:
>> Is this any more portable, by avoiding floating point division altogether?
>>
>> /* return true iff the representation of d needs a leading '-' */
>> bool
>> is_negative (long doubl
Eric Blake wrote:
> Is this any more portable, by avoiding floating point division altogether?
>
> /* return true iff the representation of d needs a leading '-' */
> bool
> is_negative (long double d)
> {
> if (d == 0)
> {
> union {
> long double d;
> long l;
> }
PS: I wrote:
> - On Alpha processors, division by zero (and even overflow!) leads to a
> SIGFPE
> signal by default. And it requires the use of a system call to change
> the FP exceptions control mask (the routines in glibc >= 2.1,
> the __setfpucw function in glibc 2.0). memcmp is
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
According to Bruno Haible on 3/25/2007 4:54 AM:
> Eric Blake wrote:
>> You can also assume IEEE rules, and compare against signed infinity:
>> 1 / +0. => +infinity
>> 1 / -0. => -infinity
>
> Nice trick :-)
>
> But here you depend on the IEEE rules f
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
According to Bruno Haible on 3/25/2007 4:54 AM:
> Eric Blake wrote:
>> You can also assume IEEE rules, and compare against signed infinity:
>> 1 / +0. => +infinity
>> 1 / -0. => -infinity
>
> Nice trick :-)
Thanks for correcting my typo; which I real
Eric Blake wrote:
> You can also assume IEEE rules, and compare against signed infinity:
> 1 / +0. => +infinity
> 1 / -0. => -infinity
Nice trick :-)
But here you depend on the IEEE rules for exceptions upon division by zero.
- On Alpha processors, division by zero (and even overflow!) leads to
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
According to Bruno Haible on 3/24/2007 7:04 PM:
> Hi,
>
> How can one distinguish +0.0 and -0.0. printf() needs to be able to do it.
> How can this be done portably? I can see two ways:
> a) By knowing the bit position of the sign bit.
> b) By doi
Hi,
How can one distinguish +0.0 and -0.0. printf() needs to be able to do it.
How can this be done portably? I can see two ways:
a) By knowing the bit position of the sign bit.
b) By doing a bit-for-bit comparison against +0.0.
The second approach appears to be implementable with less portab
16 matches
Mail list logo