[Python-Dev] test_coercion failing

Tim Peters tim.one@home.com
Wed, 21 Mar 2001 02:15:23 -0500


[Neil Schemenauer, among others confirming Linux behavior]
> There are probably lots of Linux testers around but here's what I
> get:
>
>     Python 2.1b2 (#2, Mar 20 2001, 23:52:29)
>     [GCC 2.95.3 20010219 (prerelease)] on linux2
>     Type "copyright", "credits" or "license" for more information.
>     >>> x = 0.0
>     >>> print "%.17g" % -x
>     -0
>     >>> print "%+.17g" % -x
>     -0
>
> libc is GNU 2.2.2  (if that matters).

Indeed, libc is probably the *only* that matters (Python defers to the
platform libc for float formatting).

> test_coerion works for me too.  Is test_coerce testing too much
> accidental implementation behavior?

I don't think so.  As a later message said, Jack *should* be getting a minus
0 if and only if he's running on an IEEE-754 box (extremely likely) and set
the rounding mode to minus-infinity (extremely unlikely).

But we don't yet know what the above prints on *his* box, so still don't know
whether that's relevant.

WRT display of signed zeroes (which may or may not have something to do with
Jack's problem), Python obviously varies across platforms.  But there is no
portable way in C89 to determine the sign of a zero, so we either live with
the cross-platform discrepancies, or force zeroes on output to always be
positive (in opposition to what C99 mandates).  (Note that I reject out of
hand that we #ifdef the snot out of the code to be able to detect the sign of
a 0 on various platforms -- Python doesn't conform to any other 754 rules,
and this one is minor.)

Ah, this is coming back to me now:  at Dragon this also popped up in our C++
code.  At least one flavor of Unix there also displayed -0 as if positive.  I
fiddled our output to suppress it, a la

def output(afloat):
    if not afloat:
        afloat *= afloat  # forces -0 and +0 to +0
    print afloat

(but in C++ <wink>).

would-rather-understand-jack's-true-problem-than-cover-up-a-
   symptom-ly y'rs  - tim