Re: [cc65] Problem with evaluating if with negative numbers

From: Joseph Rose <rose.joseph121yahoo.com>
Date: 2012-02-03 15:34:06
Try casting the test number to a signed number, i.e. (signed) or (signed char).
-----------------------
Joseph Rose, a.k.a. Harry Potter
Working magic in the computer community


________________________________
From: S M <san.mes@gmail.com>
To: cc65 <cc65@musoftware.de> 
Sent: Friday, February 3, 2012 8:24 AM
Subject: [cc65] Problem with evaluating if with negative numbers


Hello

I had the following line of code

if (bugs[n].mx < 0 ) {...

but it didn't work so I had to change it to:

if ( (bugs[n].mx >=128) && (bugs[1].mx <=255) ) {...

Why the first line doesn't work if .mx is not unsigned ?
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri Feb 3 15:34:21 2012

This archive was generated by hypermail 2.1.8 : 2012-02-03 15:34:24 CET