Do you have a question? Post it now! No Registration Necessary
- Subject
- Posted on
- two's compliment math
- 02-21-2006
posted on
February 21, 2006, 8:49 pm
February 21, 2006, 8:49 pm
Have been trying to do 32bit signed subtraction using two's compliment but I
can't seem to get correct figures if either (or both)of the original
operands are negative.
For a simple example in real math, 3 subtract -2 is 5, but the two's
compliment routines say the result is -1.
Am I missing something or is two's compliment unsuitable for mixed sign
subtraction?
The routines are public domain and work precisely for two positive operands
so it appears the routines are working correctly.
Do I need to go to another form of subtraction(fixed/floating point)?
What I really want is to find a quick way to find the difference between two
32bit signed numbers.
Anyone?
Thanks
JJ
Site Timeline
- » Finding a comprehensive parametric contoller directory
- — Next thread in » Microcontroller Discussions
- » Dallas MTK problem
- — Previous thread in » Microcontroller Discussions
- » ATMega ports / features - clarification
- — Newest thread in » Microcontroller Discussions
- » OT: IEEE spectrum on grid parity in China
- — The site's Newest Thread. Posted in » Electronics Design
- » Headphone vs HDMI audio
- — The site's Last Updated Thread. Posted in » Raspberry Pi Group