piclist 2001\04\01\185754a >
Thread: How to do 24bit Signed Addition/Substration Fixed point.
face BY : James Lee Williams email (remove spam text)

Actually it would matter when adding a positive integer with a negative
interger.  For example,
If I where to take this equation x1-x2 -> x_destination.
Let x1 = 15 OR 0x000F
Let x2 = 105 OR 0x0069
If I didn't handle signed math, the result of this operation would be:
FFA6 which is 65446 in decimal form.  This is clearly not the result of
this subtraction operation.
In order for me to get the correct result I have to decriment the result
if the carry bit is cleared for each of the two bytes.  Indicating a
negative result.  Then, I compliment the result in both low and upper
bytes.  This yields me a 90 result and a signe of negative.  This is the
correct result. Then, I IOR the MSB bit with one to indicate negative.
Again, to illustrate the difference between signed and unsigned would be
in simple addition.  -5 + 10.
Let x1 = 10 (0000000000001010) or 0x000A
Let x2 = - 5(1000000000000101) or 0x8005
Simple adding these would give the following result.
0x800F OR (1000000000001111).
Now when we remove the sign bit to obtain the actual value we get
0x000F, which is clearly not the result of 10 + (-5).

So in short, the mechanics is not the same.  There is definiatel some
special handling that has to take place to work with signed integers.



{Original Message removed}
<03A1C3D564C54F41AE049A641BAE0D8A070E5C@infoexch01.infoserver.no> quoted-printable

See also: www.piclist.com/techref/microchip/devices.htm?key=pic
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) How to do 24bit Signed Addition/Substration Fixed point.

month overview.

new search...