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

4 billion if statements

andreasjhkarlsson.github.io

external-link
message-square
47
fedilink
348
external-link

4 billion if statements

andreasjhkarlsson.github.io

SavvyWolf@pawb.social to Programmer Humor@programming.devEnglish · 1 year ago
message-square
47
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.
  • DarkGamer@kbin.social
    link
    fedilink
    arrow-up
    4
    arrow-down
    2
    ·
    1 year ago

    This is why every programmer needs to understand the modulo operator.

    • jaybone@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      Or bitwise AND.

      • Reptorian@programming.dev
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        This is what I prefer too! I also some times prefer to use bitshift when it comes to division or multiplication of power of 2.

    • 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@programming.dev
        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@programming.dev

programmer_humor@programming.dev

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: !programmer_humor@programming.dev

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.

  • 1.81K users / day
  • 4.5K users / week
  • 8.23K users / month
  • 17.8K users / 6 months
  • 315 local subscribers
  • 23.4K subscribers
  • 1.42K Posts
  • 52.8K Comments
  • Modlog
  • mods:
  • Feyter@programming.dev
  • adr1an@programming.dev
  • BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne@programming.dev
  • BE: 0.19.8
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org