Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Seeing if two numbers have the same sign

by WoodyWeaver (Monk)
on Jan 10, 2008 at 23:36 UTC ( [id://661756]=note: print w/replies, xml ) Need Help??


in reply to Re: Seeing if two numbers have the same sign
in thread Seeing if two numbers have the same sign

I was thinking about that! Convert to a string, and look to see if the first char is a "-" to determine sign. I don't think your routine works, though.
sub re { my $i=0; /-(?{$i=$i+1})/ for @_; $i=~/0|2/; }
given the same test cases as before,
xyxorNeg()spaceship()mult()anchor()re()
111111
-1101
1-101
-1-11111
And actually, its only twice as slow...
unit squarespaceshipmultiplylogicre
spaceship--------worse 21.74%worse 12.21%better 86.26%
multiplybetter 21.74%--------better 10.86%better 89.25%
logicbetter 12.21%worse 10.86%--------better 87.94%
reg expworse 86.26%worse 89.25%worse 87.94%--------

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://661756]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-26 05:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found