Lemmy: Bestiverse
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
RSS BotMB to Lobste.rsEnglish · 1 month ago

log is non-monotonous in PHP and Lua

purplesyringa.moe

external-link
message-square
0
link
fedilink
1
external-link

log is non-monotonous in PHP and Lua

purplesyringa.moe

RSS BotMB to Lobste.rsEnglish · 1 month ago
message-square
0
link
fedilink
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.

Comments

alert-triangle
You must log in or # to comment.

Lobste.rs

lobsters

Subscribe from Remote Instance

You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !lobsters@lemmy.bestiver.se
lock
Community locked: only moderators can create posts. You can still comment on posts.

RSS Feed of lobste.rs

Source of the RSS Bot

Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 28 users / day
  • 152 users / week
  • 399 users / month
  • 1.66K users / 6 months
  • 2 local subscribers
  • 396 subscribers
  • 15.6K Posts
  • 1.08K Comments
  • Modlog
  • mods:
  • patrick
  • RSS Bot
  • BE: 0.19.15
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org