• swag_money@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      22 hours ago

      what’s the general rule for translating negatives from binary? did you just do like 17 - 2 • (-1) or something?

      • Yardy Sardley@lemmy.ca
        link
        fedilink
        English
        arrow-up
        3
        ·
        20 hours ago

        I used what known as 2’s compliment. Take the complement (flip all the bits - here that would give you 01110 which is 14) then add 1.

        • swag_money@lemmy.world
          link
          fedilink
          English
          arrow-up
          1
          ·
          19 hours ago

          thanks for the explanation! could you express it as a NOT operation plus one? like is that how it would be processed at a low level?

          • computergeek125@lemmy.world
            link
            fedilink
            English
            arrow-up
            2
            ·
            edit-2
            6 hours ago

            My low level is a tad rusty from when I learned the C side in school, but if I recall the not operator resolves as a single Boolean (0 or 1 in true C), whereas compliment comes back as however many bits you put in - a not operation per bit.

            In C, the not operator is ! and the compliment operator is ~