Perl-Sensitive Sunglasses | |
PerlMonks |
Spaceship Zeroby Orchew (Acolyte) |
on Nov 09, 2008 at 05:40 UTC ( [id://722455]=obfuscated: print w/replies, xml ) | Need Help?? |
AFAIK there's no perl built-in function to return the sign of a number, something like sgn($x). In some languages I've used $x/abs($x), and but that won't handle zeros.
I call my solution Spaceship Zero: I'm fairly confident that, in perl, that is the shortest possible way to calculate sgn($x).
Back to
Obfuscated Code
|
|