[A86] Re: Comparing signed numbers


[Prev][Next][Index][Thread]

[A86] Re: Comparing signed numbers



In a message dated 6/9/2001 8:40:00 AM Eastern Daylight Time, 
arcadesdude@hotmail.com writes:


> Ive looked all over and this list is my last resort.
> 
> What I need to know is this:
> 
> How do you compare 2 signed (ranging from -127 to 
> 127) numbers and jr/jp on the biggest of the two?
> 
> I know for unsigned numbers its as simple as
> 
> getmax:
> ld a,1
> ld b,2
> cp b
> jr nc,aisbigger
> 
> But when working with negatives the negative number 
> is assumed bigger (because its 7th bit is set).
> 
> I looked around and saw the 'p' and 'm' flag are for 
> something like this but Im not sure if they just 
> return 'p'ositive or 'm'inus for a number or if they 
> are like the greater or less than flags (nc and c 
> respectively)
> 
> Would it be as simple as this for negative numbers?
> 
> getmaxofsigned:
> ld a,2
> ld b,-2
> cp b
> jp p,aissignedandbigger
> 

Yes.  :-)


----
Jonah Cohen
<ComAsYuAre@aol.com>
http://jonah.ticalc.org