From a8b9a01667ee136141f84cd77bfdb079e2831137 Mon Sep 17 00:00:00 2001 From: thomasabishop Date: Tue, 19 Mar 2024 07:30:04 +0000 Subject: [PATCH] Autosave: 2024-03-19 07:30:04 --- zk/Twos_complement.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/zk/Twos_complement.md b/zk/Twos_complement.md index b87c5a1..81a89f6 100644 --- a/zk/Twos_complement.md +++ b/zk/Twos_complement.md @@ -12,8 +12,32 @@ created: Tuesday, March 19, 2024 - _Two's complement_ is a method for representing signed numbers (negative integers) in binary. +- The two's complement of a given binary integer is its negative equivalent. + ## Detail +### Procedural steps + +Two's complement divides the available word length (see +[[Binary_encoding|binary encoding]]) into two subsets: one for negative integrs +and one for positive integers. + +Take the binary encoding of decimal five (`0101`). Its complement is `1011`. + +The procedure for deriving the complement is as follows. + +To derive the complement of an unsigned number: + +1. Take the unsigned number and invert its digits: `0` becomes `1`, `1` becomes + `0` +2. Add one + +![](/img/unsigned-to-signed.png) + +To derive the unsigned equivalent of a signed number + +### Formal expression + ## Applications ## Related notes