Skip to content
  • 2's complement convertion

    Solved General and Desktop complement two convert bit string
    2
    0 Votes
    2 Posts
    2k Views
    JKSHJ
    @GhostWolf said in 2's complement convertion: uint32_t test2 = (unit.value(1)<<16) | unit.value(0); Just store the result as a signed integer (int32_t) instead of unsigned (uint32_t). You don't need to change the bit pattern (0b11111111_11111111_11111111_11111111). Interpreting this pattern as Unsigned gives you ‭4294967295 Interpreting this pattern as Signed gives you -1.