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
Code Project
  1. Home
  2. The Lounge
  3. A gentle puzzle I was just asked.

A gentle puzzle I was just asked.

Scheduled Pinned Locked Moved The Lounge
questioncomlounge
80 Posts 44 Posters 1 Views 1 Watching
  • 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.
  • D dbrenth

    This was my answer as well. Both the smallest positive and largest negative integers are 0. But I can see the case for both 2 and Infinity. Brent Hoskisson

    Brent

    OriginalGriffO Offline
    OriginalGriffO Offline
    OriginalGriff
    wrote on last edited by
    #54

    Mathematically, zero is neither positive or negative ... :-D

    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
    "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

    1 Reply Last reply
    0
    • OriginalGriffO OriginalGriff

      Oh? Is -2 bigger than -1 now? :-D

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

      D Offline
      D Offline
      Davyd McColl
      wrote on last edited by
      #55

      For sure: if I have -$2, I owe the bank more than if I had -$1. $2 is a larger number, indicating a larger debt.

      ------------------------------------------------ If you say that getting the money is the most important thing You will spend your life completely wasting your time You will be doing things you don't like doing In order to go on living That is, to go on doing things you don't like doing Which is stupid. - Alan Watts https://www.youtube.com/watch?v=-gXTZM\_uPMY

      1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        What is the smallest positive integer minus the largest negative integer?

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

        J Offline
        J Offline
        Jorgen Andersson
        wrote on last edited by
        #56

        Silly me was thinking in Int32.

        Wrong is evil and must be defeated. - Jeff Ello

        1 Reply Last reply
        0
        • R raddevus

          Check this out. It's JavaScript but...

          Number.MIN_VALUE < -1 // true
          Number.NEGATIVE_INFINITY > -1 // false
          // a little clearer
          -1 > Number.NEGATIVE_INFINITY // TRUE

          So the largest negative integer is -1. :thumbsup:

          H Offline
          H Offline
          haughtonomous
          wrote on last edited by
          #57

          I think it's a bad mistake to assume that a computer implementation of a mathematical concept provides a correct definition, especially at the limits. But I agree that mathematically -1 is larger than -2. It's the distance from the extreme left of the number line (-infinity) that illustrates this. And zero is neutral, neither positive nor negative. And we're relying on ChatGPT for truth now? Lord help us!

          R J 2 Replies Last reply
          0
          • OriginalGriffO OriginalGriff

            What is the smallest positive integer minus the largest negative integer?

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

            B Offline
            B Offline
            BernardIE5317
            wrote on last edited by
            #58

            This should clear things up. Integer - Wikipedia[^]

            1 Reply Last reply
            0
            • OriginalGriffO OriginalGriff

              What is the smallest positive integer minus the largest negative integer?

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

              J Offline
              J Offline
              jarvisa
              wrote on last edited by
              #59

              The smallest positive integer is either 0 or 1 depending on whether 0 is considered positive or not. The largest negative integer is -1. So the answer is 1 or 2. This is not the intent of question but that is the correct answer given how the question was worded.

              1 Reply Last reply
              0
              • R raddevus

                MarkTJohnson wrote:

                The largest negative integer is the negative integer that is greater than all other negative integers.

                I thought the same thing. Also, isn't it interesting that on the other side of 0 that no one had a problem distinguishing the smallest positive integer : which is 1. Aren't all numbers greater than others when the are further to the right of other numbers? Also, do these people not believe that following are true? -5000 < -1 -1 > -5000 Then why don't they know that the largest negative integer is -1?

                O Offline
                O Offline
                obeobe
                wrote on last edited by
                #60

                Post-modernism.

                1 Reply Last reply
                0
                • OriginalGriffO OriginalGriff

                  What is the smallest positive integer minus the largest negative integer?

                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                  M Offline
                  M Offline
                  MikeCO10
                  wrote on last edited by
                  #61

                  Halfway through my first cup of coffee, this sent me into overthink mode, coming up with everything from infinity to zero. It took some reading of comments to see the correct answer is indeed 2. Great question Griff.

                  1 Reply Last reply
                  0
                  • OriginalGriffO OriginalGriff

                    What is the smallest positive integer minus the largest negative integer?

                    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                    M Offline
                    M Offline
                    Member 10652083
                    wrote on last edited by
                    #62

                    You have to define 'largest'.

                    OriginalGriffO 1 Reply Last reply
                    0
                    • M Member 10652083

                      You have to define 'largest'.

                      OriginalGriffO Offline
                      OriginalGriffO Offline
                      OriginalGriff
                      wrote on last edited by
                      #63

                      I don't - we have dictionaries to do that: :-D

                      Quote:

                      largest Definitions from the GNU version of the Collaborative International Dictionary of English. (adjective) Greatest in size of those under consideration. (adjective) maximal. from Wiktionary, Creative Commons Attribution/Share-Alike License. (adjective) Superlative form of large: most large.

                      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                      M 1 Reply Last reply
                      0
                      • L Lost User

                        -∞

                        J Offline
                        J Offline
                        jochance
                        wrote on last edited by
                        #64

                        ∞ + 1 Because: 1 - (-∞)

                        1 Reply Last reply
                        0
                        • OriginalGriffO OriginalGriff

                          What is the smallest positive integer minus the largest negative integer?

                          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                          M Offline
                          M Offline
                          mdblack98
                          wrote on last edited by
                          #65

                          Since this is a coding site here are the possibilities for a 32-bit int.

                          #include #include int main()
                          {
                          int pos = 1;
                          int neg = INT_MIN;
                          printf("pos=%d neg=%d\n", pos,neg);
                          printf("pos+neg=%d\n", pos+neg);
                          printf("pos-neg=%d\n", pos-neg);
                          printf("neg+pos=%d\n", neg+pos); // yes I know it's commutative but here for completeness
                          printf("neg-pos=%d\n", neg-pos);
                          return 0;
                          }

                          pos=1 neg=-2147483648
                          pos+neg=-2147483647
                          pos-neg=-2147483647 // Hmmm...this seems wrong -- subtracting negative SHOULD add it.
                          neg+pos=-2147483647
                          neg-pos=2147483647

                          1 Reply Last reply
                          0
                          • P PIEBALDconsult

                            Is zero positive?

                            M Offline
                            M Offline
                            Matt Bond
                            wrote on last edited by
                            #66

                            Depends on context. See Is zero positive or negative?

                            Bond Keep all things as simple as possible, but no simpler. -said someone, somewhere

                            P 1 Reply Last reply
                            0
                            • OriginalGriffO OriginalGriff

                              What is the smallest positive integer minus the largest negative integer?

                              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                              S Offline
                              S Offline
                              stheller2
                              wrote on last edited by
                              #67

                              2

                              1 Reply Last reply
                              0
                              • A Amarnath S

                                Smallest positive integer = 1 Largest negative integer = -1 Difference is 2.

                                J Offline
                                J Offline
                                J Tackkett
                                wrote on last edited by
                                #68

                                This person is absolutely correct. In the field of mathematics, the largest negative integer is -1. Therefore 1 - (-1) would indeed be 2.

                                1 Reply Last reply
                                0
                                • A Amarnath S

                                  Smallest positive integer = 1 Largest negative integer = -1 Difference is 2.

                                  K Offline
                                  K Offline
                                  kholsinger
                                  wrote on last edited by
                                  #69

                                  My brain went to 2s complement, and also considers largest negative int to be -128 for 8 bits, -32768 for 16 bits. As someone else said, my creditors consider think I owe them a larger amount if it's $32,768 instead of $1. But then my brain fried.... I know it would over or underflow, but exactly how? Hmm.... I've spent so many years programming to avoid such overflows that I no longer remember. Does it depend on the compiler? C# example: Int16 a = 1; Int16 b = -32768; Int16 c = (Int16)(a - b); C winds up being -32767, which means it wound up doing the 16 bit equivalent of (0001 - 1000) = 1001 in binary. The LSB being one makes sense to me. The MSB being one is not so obvious.

                                  1 Reply Last reply
                                  0
                                  • M Matt Bond

                                    Depends on context. See Is zero positive or negative?

                                    Bond Keep all things as simple as possible, but no simpler. -said someone, somewhere

                                    P Offline
                                    P Offline
                                    PIEBALDconsult
                                    wrote on last edited by
                                    #70

                                    Zero is definitely not negative. And it's not imaginary either. If it's neither positive nor negative, then it must also be neither imaginary nor real. If we accept zero as a real, then we must conclude that zero is positive.

                                    1 Reply Last reply
                                    0
                                    • R RainHat

                                      It can be positive, negative or unsigned depending on the representation and how it is used. Fnu

                                      P Offline
                                      P Offline
                                      PIEBALDconsult
                                      wrote on last edited by
                                      #71

                                      As a particular representation, perhaps. But what about as a pure concept?

                                      J 1 Reply Last reply
                                      0
                                      • H haughtonomous

                                        I think it's a bad mistake to assume that a computer implementation of a mathematical concept provides a correct definition, especially at the limits. But I agree that mathematically -1 is larger than -2. It's the distance from the extreme left of the number line (-infinity) that illustrates this. And zero is neutral, neither positive nor negative. And we're relying on ChatGPT for truth now? Lord help us!

                                        R Offline
                                        R Offline
                                        raddevus
                                        wrote on last edited by
                                        #72

                                        haughtonomous wrote:

                                        a bad mistake to assume that a computer implementation of a mathematical concept provides a correct definition,

                                        Oh, wow, there's a lot packed into that, because it would be odd if computer languages were also wrong about mathematical concepts, wouldn't it? Logic would be wrong and all kinds of things. Of course, I do understand that a language only models mathematical concepts. But it would be a huge exposure if programming languages didn't define mathematical concepts properly, i think.

                                        haughtonomous wrote:

                                        And zero is neutral, neither positive nor negative.

                                        I agree 100% on that.

                                        haughtonomous wrote:

                                        And we're relying on ChatGPT for truth now?

                                        No, I'm not depending on it. I am curious about what chatGPT thinks tho, because, in my experience, it hallucinates (lies) often.

                                        1 Reply Last reply
                                        0
                                        • OriginalGriffO OriginalGriff

                                          I don't - we have dictionaries to do that: :-D

                                          Quote:

                                          largest Definitions from the GNU version of the Collaborative International Dictionary of English. (adjective) Greatest in size of those under consideration. (adjective) maximal. from Wiktionary, Creative Commons Attribution/Share-Alike License. (adjective) Superlative form of large: most large.

                                          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                                          M Offline
                                          M Offline
                                          Member 10652083
                                          wrote on last edited by
                                          #73

                                          That is no help whatsoever for your mathematical usage here.

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


                                          • Login

                                          • Don't have an account? Register

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