Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Programmer Humor
  3. WishUnderflow

WishUnderflow

Scheduled Pinned Locked Moved Programmer Humor
programmerhumor
41 Posts 35 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • merari42@lemmy.worldM This user is from outside of this forum
    merari42@lemmy.worldM This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #1
    This post did not contain any content.
    E J savvywolf@pawb.socialS T P 14 Replies Last reply
    468
    • merari42@lemmy.worldM [email protected]
      This post did not contain any content.
      E This user is from outside of this forum
      E This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #2

      wouldn't 0 be 0 and -1 underflow to 255 if 8 bit container? intentional error to enhance engagement?

      K H 2 Replies Last reply
      53
      • merari42@lemmy.worldM [email protected]
        This post did not contain any content.
        J This user is from outside of this forum
        J This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #3

        "Subtract 4 wishes"

        1 Reply Last reply
        8
        • E [email protected]

          wouldn't 0 be 0 and -1 underflow to 255 if 8 bit container? intentional error to enhance engagement?

          K This user is from outside of this forum
          K This user is from outside of this forum
          [email protected]
          wrote on last edited by [email protected]
          #4

          You're correct but you have an off by 1 error.

          First, the genie grants the wish.

          NumWishes=0;

          Then, having completed the wish, the genie deducts that wish from the remaining wishes.

          NumWishes--;

          And to complete the thought,

          Lastly, the genie checks if the lampholder is out of wishes

          If(NumWishes==0)
          {...}

          (255==0) evaluates to False, so we fall past that check.

          Q dumhuvud@programming.devD 2 Replies Last reply
          73
          • E [email protected]

            wouldn't 0 be 0 and -1 underflow to 255 if 8 bit container? intentional error to enhance engagement?

            H This user is from outside of this forum
            H This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #5

            Genie reduced number of wishes to 0. But by doing so he granted one of the wishes, so it became -1 (255).

            1 Reply Last reply
            7
            • K [email protected]

              You're correct but you have an off by 1 error.

              First, the genie grants the wish.

              NumWishes=0;

              Then, having completed the wish, the genie deducts that wish from the remaining wishes.

              NumWishes--;

              And to complete the thought,

              Lastly, the genie checks if the lampholder is out of wishes

              If(NumWishes==0)
              {...}

              (255==0) evaluates to False, so we fall past that check.

              Q This user is from outside of this forum
              Q This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #6

              This is actually genius

              1 Reply Last reply
              7
              • merari42@lemmy.worldM [email protected]
                This post did not contain any content.
                savvywolf@pawb.socialS This user is from outside of this forum
                savvywolf@pawb.socialS This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #7

                I had a visceral reaction to this because obviously the wish count should be decremented before the wish takes place. Even though I can't think up a convincing technical argument for it.

                B skullgrid@lemmy.worldS T 3 Replies Last reply
                30
                • savvywolf@pawb.socialS [email protected]

                  I had a visceral reaction to this because obviously the wish count should be decremented before the wish takes place. Even though I can't think up a convincing technical argument for it.

                  B This user is from outside of this forum
                  B This user is from outside of this forum
                  [email protected]
                  wrote on last edited by
                  #8

                  If there's parallelism/async involved, then there definitely is an argument to decrement first, execute later. Otherwise you could make a wish for the genie to just wait for an hour and then make as many wishes as you want within that hour.

                  B gutek8134@lemmy.worldG 2 Replies Last reply
                  11
                  • merari42@lemmy.worldM [email protected]
                    This post did not contain any content.
                    T This user is from outside of this forum
                    T This user is from outside of this forum
                    [email protected]
                    wrote on last edited by
                    #9

                    You fool, you've unleashed ghandi's thermonuclear rage!

                    1 Reply Last reply
                    3
                    • K [email protected]

                      You're correct but you have an off by 1 error.

                      First, the genie grants the wish.

                      NumWishes=0;

                      Then, having completed the wish, the genie deducts that wish from the remaining wishes.

                      NumWishes--;

                      And to complete the thought,

                      Lastly, the genie checks if the lampholder is out of wishes

                      If(NumWishes==0)
                      {...}

                      (255==0) evaluates to False, so we fall past that check.

                      dumhuvud@programming.devD This user is from outside of this forum
                      dumhuvud@programming.devD This user is from outside of this forum
                      [email protected]
                      wrote on last edited by
                      #10

                      Yeah, but what if the counter gets decremented before the wish gets granted, huh?

                      S M K mesa@programming.devM S 5 Replies Last reply
                      32
                      • dumhuvud@programming.devD [email protected]

                        Yeah, but what if the counter gets decremented before the wish gets granted, huh?

                        S This user is from outside of this forum
                        S This user is from outside of this forum
                        [email protected]
                        wrote on last edited by
                        #11

                        I love being a nerd

                        E 1 Reply Last reply
                        10
                        • savvywolf@pawb.socialS [email protected]

                          I had a visceral reaction to this because obviously the wish count should be decremented before the wish takes place. Even though I can't think up a convincing technical argument for it.

                          skullgrid@lemmy.worldS This user is from outside of this forum
                          skullgrid@lemmy.worldS This user is from outside of this forum
                          [email protected]
                          wrote on last edited by
                          #12

                          I had a visceral reaction to this because obviously the wish count should be decremented before the wish takes place.

                          Why? Shouldn't you decrement the limited resource the user has access to in case the thing you are doing fails?

                          1 Reply Last reply
                          4
                          • B [email protected]

                            If there's parallelism/async involved, then there definitely is an argument to decrement first, execute later. Otherwise you could make a wish for the genie to just wait for an hour and then make as many wishes as you want within that hour.

                            B This user is from outside of this forum
                            B This user is from outside of this forum
                            [email protected]
                            wrote on last edited by
                            #13

                            But how can you decrement a future dated wish, since you can't guarantee nothing will happen that prevents the genies ability from executing said wish? E.g. i mean like telling the Genie to do something 5 days from now, not your example which would begin immediately after making said wish.

                            B C 2 Replies Last reply
                            2
                            • merari42@lemmy.worldM [email protected]
                              This post did not contain any content.
                              P This user is from outside of this forum
                              P This user is from outside of this forum
                              [email protected]
                              wrote on last edited by
                              #14

                              Then you find out the genie uses a signed data value and you now owe him a wish. You're not granted magic. You're compelled to grant the wish. The only restrictions on the genie's wish is that it must be within your (soft, squishy) mortal power.

                              I can imagine you being reset to the point of the genie's wish every time you die (naturally or otherwise) without succeeding. This could well turn into a Groundhog Day type situation.

                              X 1 Reply Last reply
                              13
                              • merari42@lemmy.worldM [email protected]
                                This post did not contain any content.
                                S This user is from outside of this forum
                                S This user is from outside of this forum
                                [email protected]
                                wrote on last edited by [email protected]
                                #15

                                Should've been "make -1 wishes" 0 is 0

                                Edit:oh I get it. First the gene fullfill the wish then subtract one from the 0 wishes.

                                1 Reply Last reply
                                3
                                • B [email protected]

                                  But how can you decrement a future dated wish, since you can't guarantee nothing will happen that prevents the genies ability from executing said wish? E.g. i mean like telling the Genie to do something 5 days from now, not your example which would begin immediately after making said wish.

                                  B This user is from outside of this forum
                                  B This user is from outside of this forum
                                  [email protected]
                                  wrote on last edited by
                                  #16

                                  You decrement the wish counter first, execute the action (which includes waiting those 5 days), and if it fails you increment the counter back. Something like this:

                                  wishes = wishes - 1;
                                  executeWish(wish).unwrap_or_else(|_| { wishes = wishes + 1; })?
                                  

                                  This way if the action fails in the future, you get a wish back and can ask something else.

                                  1 Reply Last reply
                                  3
                                  • merari42@lemmy.worldM [email protected]
                                    This post did not contain any content.
                                    M This user is from outside of this forum
                                    M This user is from outside of this forum
                                    [email protected]
                                    wrote on last edited by
                                    #17

                                    Now make it 2.5 wishes. Now 0.9. Now 999.

                                    T J L 3 Replies Last reply
                                    8
                                    • dumhuvud@programming.devD [email protected]

                                      Yeah, but what if the counter gets decremented before the wish gets granted, huh?

                                      M This user is from outside of this forum
                                      M This user is from outside of this forum
                                      [email protected]
                                      wrote on last edited by
                                      #18

                                      I would assume this to be the case since you cannot un-utter a wish—once you say it, it is counted as a wish before it's fulfilled.

                                      If the counter is decremented only after the wish is fulfilled, then this means you can go back on wishes because they don't count until they're fulfilled, which goes against the lore.

                                      K W 2 Replies Last reply
                                      0
                                      • M [email protected]

                                        Now make it 2.5 wishes. Now 0.9. Now 999.

                                        T This user is from outside of this forum
                                        T This user is from outside of this forum
                                        [email protected]
                                        wrote on last edited by
                                        #19

                                        Found the QA tester.

                                        1 Reply Last reply
                                        7
                                        • M [email protected]

                                          Now make it 2.5 wishes. Now 0.9. Now 999.

                                          J This user is from outside of this forum
                                          J This user is from outside of this forum
                                          [email protected]
                                          wrote on last edited by
                                          #20

                                          After you made it 0.9 you no longer have enough wishes left.

                                          1 Reply Last reply
                                          4
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups