On Wed, Jul 28, 2010 at 02:11:00PM -0400, Chas. Owens wrote: > On Wed, Jul 28, 2010 at 11:58, Nicholas Clark <nick@ccl4.org> wrote: > snip > > If you're up for it, I don't think that it's documented anywhere that the > > false value returned by a logical operator is a special case: > > > > $ perl -wle '$a = 0 == 1; print ">$a<"; print $a + 0' > >>< > > 0 > > > > it is both the empty string, and a numeric zero. > > (That's not a special case in any conversion code. It's a dual value) > snip > > Yeah, I missed that when I documented the relational and equality > operators in perlopquick. I will go back and add that detail to them. Cool, thanks. > snip > > Also, $! is a dual value, with the string value being the error string, and > > numeric value being the error code. On this system, the error string for 0 > > *is* an empty string, hence this is false: > > > > $ perl -wle '$! = 0; print ">$!<"; print $! + 0' > >>< > > 0 > snip > > I think that is fairly well documented in perlvar. Good. > snip > > 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? That was x86 Linux. I believe there's a few of them left. :-) [It's IEEE floating point, not integers. I believe that the only one's complement architecture that I'm aware of Perl 5 building on was Amdahl Mainframes, and we've not seen one of them for longer than whichever type of Crays were fun] Nicholas ClarkThread Previous | Thread Next