piclist 2001\03\09\122855a >
Thread: Comparison of signed 16bit values from addition orsubtraction
www.piclist.com/techref/microchip/devices.htm?key=pic
flavicon
face BY : Nikolai Golovchenko email (remove spam text)



Walter Banks wrote:
> This is the technique used by most compilers (including MPC) on
> processors that do not have an overflow bit for comparing
> signed numbers.

Cool, I didn't know that.

>  Careful implementation can also use this
> technique for comparing signed and unsigned numbers of the
> same number of bits without casting to a larger number of bits.

Let me guess. If the most significant bit of the unsigned number is
set, than it's bigger and you quit. If not, the sign bits are inverted
for both numbers and then compared as if they are both unsigned.
Right?

I think you can even do some math using the biased representation. It
is probably not much different from the usual unsigned, if you track
the bias value. Interesting, is someone using that representation for
more than just comparison?

> The nice thing about using a biased representation to
> do the comparison is that exclusive or can be used to add the
> bias to the number (or invert the sign bit) This is important
> because in most compact implementations the carry bit needs
> to be preserved during at least one one of these operations.

> Walter Banks

Nikolai

{Quote hidden}

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


<223572764.20010309192833@yahoo.com> 7bit

In reply to: <3AA8BF39.A5ED4417@bytecraft.com>
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) Comparison of signed 16bit values from addition orsubtraction

month overview.

new search...