programming.dev
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
SavvyWolf@pawb.social to Programmer HumorEnglish · 1 year ago

4 billion if statements

andreasjhkarlsson.github.io

external-link
message-square
47
link
fedilink
350
external-link

4 billion if statements

andreasjhkarlsson.github.io

SavvyWolf@pawb.social to Programmer HumorEnglish · 1 year ago
message-square
47
link
fedilink
I recently stumbled upon this screenshot while researching social media on the train. Of course, it was followed by a cascade of spiteful comments, criticizing this fresh programmer’s attempt to solve a classical problem in computer science. The modulus operation.
  • MxM111@kbin.social
    link
    fedilink
    arrow-up
    3
    arrow-down
    1
    ·
    1 year ago

    I would divide by two (floating point) and check the fractional part.

    • sus
      link
      fedilink
      arrow-up
      6
      ·
      1 year ago

      turns out that 2^53 + 1 is an even number

      • iknowitwheniseeit@lemmynsfw.com
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        The article only covers unsigned 32-bit numbers, so floating point division would be fine.

Programmer Humor

programmer_humor

Subscribe from Remote Instance

Create a post
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: [email protected]

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
Visibility: Public
globe

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

  • 2.04K users / day
  • 5.35K users / week
  • 9.15K users / month
  • 18.5K users / 6 months
  • 2.41K local subscribers
  • 23.6K subscribers
  • 1.43K Posts
  • 54K Comments
  • Modlog
  • mods:
  • adr1an
  • Feyter
  • BurningTurtle
  • Pierre-Yves Lapersonne
  • BE: 0.19.11
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org