Get the latest tech news
Log is non-monotonic in PHP and Lua
If a b 1 and x 1 , you can prove that log a x log b x . (As a reminder, log a x denotes the value t such that x = a t .) This is very intuitive if you think about it: for “normal” numbers, the greater a , the smaller t you will need to get the same x . Yet if you ask PHP what it thinks, it will tell you you’re wrong in a couple rare cases: $x = 2.93; $a = 10 + 2 ** -49; $b = 10; assert($a $b); var_dump(log($x, $a) log($x, $b)); var_dump(log($x, $a) == log($x, $b)); To be clear, this is not the usual floating-point inaccuracy. Everyone already knows floating-point operations are imprecise and it wouldn’t be fun to blog about. This example was deliberately engineered to trigger something different.
None
Or read this on Hacker News
