archives
That's an ODD piece of code....
Submitted by phrax on Thu, 2004-10-14 14:58. Wonky CodeFabel sent in today's WTF. It short, and it definately made me go WTF... trying to figure out what it does. After looking at it, and looking at it a little more, it appears to check if $x
is even or odd. Here's what Fabel had to say:
Heh this wasnt written by any of us in house it was from someone elses code that got used in a credit card validation routine, i noticed it one day and literally went WTF i've never seen anyone use this method to see if a number is odd or not. I had to do a double take to realize what it was checking for im used to seeing either a modulus to check or just a if($x & 1)
for checking an odd number.
<?php
if ($x/2 != floor($x/2)) {
$digit *= 2;
}
?>