How do I solve problems with decimals using 2's complement arithmetic?

  • Context: Undergrad 
  • Thread starter Thread starter Caldus
  • Start date Start date
  • Tags Tags
    Arithmetic
Click For Summary
SUMMARY

The discussion focuses on solving arithmetic problems involving decimals using 2's complement arithmetic. Specifically, it addresses the sum and difference of +17.5 and -43.25 in a 12-digit binary format. The process involves converting the decimal numbers to binary, applying 2's complement for negative values, and performing the arithmetic operations. The key steps include representing the numbers in binary, transforming them into 2's complement, and converting the results back to decimal.

PREREQUISITES
  • Understanding of 2's complement arithmetic
  • Knowledge of binary representation of decimal numbers
  • Familiarity with fixed-point binary formats
  • Basic arithmetic operations (addition and subtraction) in binary
NEXT STEPS
  • Research fixed-point binary representation techniques
  • Learn about converting decimal numbers to binary and vice versa
  • Study the application of 2's complement in negative number representation
  • Explore binary arithmetic operations in detail
USEFUL FOR

Students, computer scientists, and engineers working with digital systems, particularly those involved in low-level programming or hardware design requiring binary arithmetic operations.

Caldus
Messages
106
Reaction score
0
How do you do this problem?

Sum of +17.5 (Base 10) and -43.25 (Base 10) using 2's complement arithmetic.
Difference of +17.5 (Base 10) and -43.25 (Base 10) using 2's complement arithmetic.

The binary representations must have 12 digits. How the heck do I solve a problem with decimals like this? Thanks for any assistance.
 
Mathematics news on Phys.org
Originally posted by Caldus
How do you do this problem?

Sum of +17.5 (Base 10) and -43.25 (Base 10) using 2's complement arithmetic.
Difference of +17.5 (Base 10) and -43.25 (Base 10) using 2's complement arithmetic.

The binary representations must have 12 digits. How the heck do I solve a problem with decimals like this? Thanks for any assistance.

ok, some quick thoughts...
1) first represent the numbers 17.5 and 43.25 in usual binary format. The integer part can be represented by 6 bits + 1 sign bit, and the fractional part can be represented by 2 bits, so you'll need a total of 9 bits. The remaining 12 - 9 = 3 bits can be put either on the ineger or on the fractional part of the number...
2) transform the 2 binary numbers you've obtained in 2's complement
3) add, respectively subtract
4) reconvert the result in normal binary form, and then to decimal, see if you've got the correct result
 
Originally posted by Caldus

The binary representations must have 12 digits. How the heck do I solve a problem with decimals like this? Thanks for any assistance.

Easy, just stick in a (fixed) "decimal" point two digits from the left and then use ordinary two's complement. (like just ingnore the "decimal point" and it will work anyway).

Example (5 bit = xxx.xx)

3.5 = 011.10

-3.5 = 2's_comp(3.5) = 1000.00 - 011.10
= 100.10

Now let's test -3.5 in some computations.

3.5 + (-3.5) =
____011.10 +
____100.10
=(1)000.00 As expected



3.75 + (-3.5) =
____011.11 +
____100.10
=(1)000.01 As expected



2.5 + (-3.5) =
_010.10 +
_100.10
=111.00 This is (-1.00) as expected

Note that 2's_comp(111.00) = 1000.00 - 111.00 = 001.00
 
Last edited:

Similar threads

  • · Replies 1 ·
Replies
1
Views
1K
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 15 ·
Replies
15
Views
5K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
10K
  • · Replies 12 ·
Replies
12
Views
4K
Replies
9
Views
4K
Replies
1
Views
2K