Re: Signed zeros: is this a bug?
- From: Duncan Booth <duncan.booth@xxxxxxxxxxxxxxx>
- Date: 11 Mar 2007 17:21:10 GMT
"Mark Dickinson" <dickinsm@xxxxxxxxx> wrote:
I guess what's happening is that there's some optimization that avoids
creating two separate float objects for a float literal that appears
twice, and that optimization doesn't see the difference between 0. and
-0.
Don't guess. Test.
x = 0.0def f():
y = -0.0
return x, y
2 0 LOAD_CONST 1 (0.0)dis.dis(f)
3 STORE_FAST 0 (x)
3 6 LOAD_CONST 1 (0.0)
9 STORE_FAST 1 (y)
4 12 LOAD_FAST 0 (x)
15 LOAD_FAST 1 (y)
18 BUILD_TUPLE 2
21 RETURN_VALUE
Yes. Just the one constant there.
Tim Peters wrote in
http://blog.gmane.org/gmane.comp.python.devel/day=20050409:
All Python behavior in the presence of a NaN, infinity, or signed zero
is a platform-dependent accident. This is because C89 has no such
concepts, and Python is written to the C89 standard. It's not easy to
fix across all platforms (because there is no portable way to do so in
standard C), although it may be reasonably easy to fix if all anyone
cares about is gcc and MSVC (every platform C compiler has its own set
of gimmicks for "dealing with" these things).
.
- Follow-Ups:
- Re: Signed zeros: is this a bug?
- From: Alex Martelli
- Re: Signed zeros: is this a bug?
- From: Mark Dickinson
- Re: Signed zeros: is this a bug?
- References:
- Signed zeros: is this a bug?
- From: Mark Dickinson
- Re: Signed zeros: is this a bug?
- From: Dan Bishop
- Re: Signed zeros: is this a bug?
- From: Terry Reedy
- Re: Signed zeros: is this a bug?
- From: Mark Dickinson
- Signed zeros: is this a bug?
- Prev by Date: Re: Parsing Indented Text (like parsing Python)
- Next by Date: Re: Signed zeros: is this a bug?
- Previous by thread: Re: Signed zeros: is this a bug?
- Next by thread: Re: Signed zeros: is this a bug?
- Index(es):