develooper Front page | perl.perl5.porters | Postings from July 2010

RE: [perl #76756] PATCH: srand returns the seed

Thread Previous | Thread Next
From:
Jan Dubois
Date:
July 28, 2010 12:01
Subject:
RE: [perl #76756] PATCH: srand returns the seed
Message ID:
069001cb2e87$40fff510$c2ffdf30$@activestate.com
On Wed, 28 Jul 2010, Chas. Owens wrote:
> On Wed, Jul 28, 2010 at 11:58, Nicholas Clark <nick@ccl4.org> wrote:
> > And if you're really up for it, there's a bug with no obvious fix if your
> > system supports negative zero:
> >
> > $ perl -wle '$a = 0/-1; print $a ? "T" : "F"; print $a; print $a ? "T" : "F";'
> > F
> > -0
> > T
> snip
> 
> That only happens on one's complement machines right?  Are there any
> one's complement machines left?

No, it happens (at least) for all machines with IEEE 754 floating point.

There is no -0 integer, as you correctly point out, but there is a -0. float.
Just run Nicholas' oneliner on any x86/x64 chip to see that it does what he
said it does...

Cheers,
-Jan


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About