Even more hexadecimal fun

Some functions working on floats accept hexadecimal numbers while others don't:

<?php
print sin('15');
print
sin('0xF');
var_dump(round('15'));
var_dump(round('0xF'));
?>

You will see a float(0) for the second one if your PHP version is lower than 5.3.0. In PHP 5.3.0 and ongoing, both of these functions support hexadecimal numbers, however the explicit casting still does not.

Props go to Stan Vassilev for this one and also in general for being a great source of WTFs :)

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options