• dual_sport_dork 🐧🗡️@lemmy.worldM
      link
      fedilink
      English
      arrow-up
      7
      ·
      edit-2
      5 days ago

      Give that man a cigar.

      2^16 is 65,536 precisely, one less than that is the number in question. 65,535 is the maximum value of an unsigned 16 bit integer, i.e. sixteen ones in binary: 1111111111111111.

      Any nerd who has spent enough time around computers, or at least old computer games, will recognize that instantly as well as the maximum of an 8 bit integer (255) and 32 bit integer (4,294,967,295) because these are inevitably the values you see on your score/money/ammo/whatever counter when you bork your game. Deliberately or otherwise.

      • DarkSirrush@lemmy.ca
        link
        fedilink
        arrow-up
        1
        ·
        6 days ago

        Fun fact: the maximum amount of money you can hold in Maple story is actually half the 32 bit maximum, at 2,147,483,647.

        • dual_sport_dork 🐧🗡️@lemmy.worldM
          link
          fedilink
          English
          arrow-up
          7
          ·
          6 days ago

          That means it’s being stored as a signed integer for some reason. The other half of the binary space is for the negative values, which was probably a poor choice. Unless there is a valid case when you can have negative money. Is debt a thing in Maple Story?

          • DarkSirrush@lemmy.ca
            link
            fedilink
            arrow-up
            3
            ·
            6 days ago

            Not at all, but it definitely used to get exploited a lot back in the day.

            I bet they thought using signed integers made math easier or something.

    • Tarquinn2049@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      5 days ago

      Yeah, off-by-one errors are the most common error in programming, and when you are off by +1, and then try to bring it down to 0, it rolls over to max value instead. It makes sense, since some things use 0 as 1 and some things use 1 as 1. The programmer usually just has to memorize which is which… so yeah. Not surprising that it is the most common cause of bugs.