Autosave: 2024-03-19 07:10:03
This commit is contained in:
parent
3c795f4b20
commit
1f11a23e6e
1 changed files with 10 additions and 8 deletions
|
@ -4,15 +4,18 @@ tags: [binary, binary-encoding]
|
||||||
|
|
||||||
# Signed and unsigned numbers
|
# Signed and unsigned numbers
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
- To represent negative integers in binary we use signed numbers.
|
||||||
|
|
||||||
In order to represent negative integers in binary we use signed numbers.
|
In order to represent negative integers in binary we use signed numbers.
|
||||||
**Signed binary** is basically binary where negative integers can be
|
**Signed binary** is basically binary where negative integers can be
|
||||||
represented. **Unsigned binary** is standard binary without negative integers.
|
represented. **Unsigned binary** is standard binary without negative integers.
|
||||||
|
|
||||||
In order to represent negative integers alonside positive integers a natural
|
In order to represent negative integers alonside positive integers a natural
|
||||||
approach is to divide the available
|
approach is to divide the available
|
||||||
[encoding space / word length](Binary_encoding.md)
|
[encoding space / word length](Binary_encoding.md) into two subsets: one for
|
||||||
into two subsets: one for representing non-negative integers and one for
|
representing non-negative integers and one for representing negative integers.
|
||||||
representing negative integers.
|
|
||||||
|
|
||||||
The primary method for doing this is to use _two's complement_. This method
|
The primary method for doing this is to use _two's complement_. This method
|
||||||
makes signed numbers possible in a way that complicates the hardware
|
makes signed numbers possible in a way that complicates the hardware
|
||||||
|
@ -83,9 +86,8 @@ inverting the bits.)
|
||||||
The chief advantage of the two's complement technique of signing numbers is that
|
The chief advantage of the two's complement technique of signing numbers is that
|
||||||
its circuit implementation is no different from the adding of two unsigned
|
its circuit implementation is no different from the adding of two unsigned
|
||||||
numbers. Once the signing algorithm is applied the addition can be passed
|
numbers. Once the signing algorithm is applied the addition can be passed
|
||||||
through an
|
through an [adder](Half_adder_and_full_adder.md) component without any special
|
||||||
[adder](Half_adder_and_full_adder.md)
|
handling or additional hardware.
|
||||||
component without any special handling or additional hardware.
|
|
||||||
|
|
||||||
Let's demonstrate this with the following addition:
|
Let's demonstrate this with the following addition:
|
||||||
|
|
||||||
|
@ -119,8 +121,8 @@ The ease by which we conduct signed arithmetic with standard hardware contrasts
|
||||||
with alternative approaches to signing numbers. An example of another approach
|
with alternative approaches to signing numbers. An example of another approach
|
||||||
is **signed magnitude representation**. A basic implemetation of this would be
|
is **signed magnitude representation**. A basic implemetation of this would be
|
||||||
to say that for a given bit-length (6, 16, 32...) if the
|
to say that for a given bit-length (6, 16, 32...) if the
|
||||||
[most significant bit](Half_adder_and_full_adder.md#binary-arithmetic)
|
[most significant bit](Half_adder_and_full_adder.md#binary-arithmetic) is a 0
|
||||||
is a 0 then the number is positive. If it is 1 then it is negative.
|
then the number is positive. If it is 1 then it is negative.
|
||||||
|
|
||||||
This works but it requires extra complexity to in a system's design to account
|
This works but it requires extra complexity to in a system's design to account
|
||||||
for the bit that has a special meaning. Adder components would need to be
|
for the bit that has a special meaning. Adder components would need to be
|
||||||
|
|
Loading…
Add table
Reference in a new issue