Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: monkey0506 on Fri 17/11/2006 05:16:50

Title: X * -1 (Multiplication by negative numbers) (bug?)
Post by: monkey0506 on Fri 17/11/2006 05:16:50
Hmmm...this seems a bit odd, but I was just trying to do some multiplication by -1, and AGS kept generating an "inproper use of operator '*'" error. I fixed it by doing it like (x * (-1)) instead of (x * -1). I'm pretty sure that's a bug...but it could just be me.
Title: Re: X * -1 (Multiplication by negative numbers) (bug?)
Post by: Janik on Fri 17/11/2006 06:40:16
In a similar vein, a line like

i = +1;

will give an "unexpected operator" error. Also easy to avoid, but it's not normal behavior for most programming languages.
Title: Re: X * -1 (Multiplication by negative numbers) (bug?)
Post by: Scorpiorus on Fri 17/11/2006 07:47:53
Yeah, I think something like this was mentioned before and it's generally a minor issue since we don't write "x*-1 or "x+-1" as a common case.

I guess you got it with macros, so we then use parenthesis to wrap a negative value as you suggest:

#define CONST (-1)

int value = 1 + CONST;
Title: Re: X * -1 (Multiplication by negative numbers) (bug?)
Post by: Radiant on Fri 17/11/2006 11:29:54
Try " X = -X " instead.