Thursday, December 15, 2011

Does anyone know fixed-point binary?

How do I calculate the range of fixed-point binary for both signed and unsigned numbers? I know it doesn't work the same for signed/unsigned integers, i just cant figure it out.





here is an example:





What is the range of a 11b code,


a. using Unsigned Fixed-point with 8 binary places


b. Signed fixed-point with 8 binary places





please explain what you did step by step by explaining the equation and what all the variables mean.





thanks|||Unsigned single precision arithmetic uses all 8 bits as magnitude bits. It is straight binary 00000000 to 11111111 or 0 to 255 decimal.


Signed single precision arithmetic uses numbers in twos compliment form. The most significant bit is the sign bit followed by seven magnitude bits. If the sign bit is a 0 it is positive and a 1 is negative. Positive numbers range from


00000000 to 011111111 or 0 to 127 ( 0 zero is a positive number). positive numbers are straight binary numbers.


Negative numbers are a little tricky.


Negative numbers range from 11111111 to 100000000 or -1 to -128.


To convert a positive number to a negative number do a ones compliment (compliment all the numbers ie all ones are changed to zeroes and all the zeroes to ones). Then add one and that is twos compliment.





For example the number 75 (decimal) is 01001011 in binary. It is also a positive number, the sign bit is zero. To convert 010001011 to a negative number do ones compliment.


010001011 positive number 75


101110100 ones compliment


101110101 add 1 equals -75 note the sign bit





Add +75 and -75 Note * place holder 9th column.


*010001011


*101110101


------------------


100000000 The carry (under the astric) is discarded the answer is a positive zero. Overflow is cleared.





Don't get me started on the definition of overflow - -when the processor accidently makes a mistake. Ppppplease.





Overflow looks at the sign bits. If you add two positive numbers the answer should be positive a condition of overflow clear. If you add two positive numbers and get a negative number that is a condition of overflow set and a wrong answer (double or mutiple precision is required for a correct answer). Overflow is always cleared when adding a positive and negative or negative and positive. Subtraction works the same way.





Sorry I got so long winded.





D.bumstead|||For signed integers, where n is the number of bits, the largest positive number is


2^(n-1) -1 and the largest negative number is -(2^(n-1)). For fixed point binary numbers, you divide by a power of 2.

No comments:

Post a Comment