Determine the minimum register size

0

I am actually new to embedded systems. I have a question on determining the minimum register size to store a particular value. Here is the question:

  1. Why do it need a minimum of 8 bits register size to store 0xFFFFFFF1 (signed numbers)
  2. Why do it need a minimum of 16 bits register size to store 0b010010110111 (signed numbers)
embedded
bit
cpu-registers
signed
asked on Stack Overflow Mar 22, 2014 by Law • edited Mar 31, 2014 by BenMorel

1 Answer

0

Sounds like this exercise is to get you to understand where the sign bit is in a signed number or where the sign bits are since they sign extend forever. A positive number will have an infinite number of 0s and a negative an infinite number of 1s. so long as you have at least one you can represent that number so your first one is 1111....1110001 the sign bit starts on bit 4 so it only takes a 5 bit register minimum to hold that number. Your second example 0b010010110111 we have to assume the msbit there sign extends and in that case bit 11 indicates sign so you at minimum need a 12 bit register. Now if your processor does not have a 5 bit then whatever the next size up is the minimum (8?). And if your processor does not have a 12 bit register then the next size up is 16.

answered on Stack Overflow Mar 22, 2014 by old_timer

User contributions licensed under CC BY-SA 3.0