To make it extremely simple, consider the code:
At last, a technical argument. For safety.
This
sub odd { die 'Out of integer range' if $_[ 0 ] & 0xffffffff != $_[ 0 ]; ## Should be done by perl! return $_[ 0 ] & 1; }
Versus this
sub odd { my $num= shift @ARGV; die 'Number too big to test for oddness' if $num > 9_007_199_254_740__992; die 'Number too small to test for oddness' if $num < -9_007_199_254_740__992; die 'Cannot test #INFinity for oddness' if $num eq '1.#INF'; die 'Cannot test negative #INFinity for oddness' if $num eq '-1.#INF'; die 'Cannot test #IND for oddness' if $num eq '1.#IND'; die 'Cannot test negative #IND for oddness' if $num eq '-1.#IND'; die 'Cannot test a non number for oddness' if $num eq '1.#QNAN; die 'Cannot test negative non number for oddness' if $num eq '-1.#QNAN; die 'Cannot test a non-integer for oddness' if int( $num ) != $num; return $num % 2 ? 1 : 0; }
In reply to Re^7: &1 is no faster than %2 when checking for oddness. Oh well. (best)
by BrowserUk
in thread &1 is no faster than %2 when checking for oddness. Oh well.
by diotalevi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |