X * -1 (Multiplication by negative numbers) (bug?)

Started by monkey0506, Fri 17/11/2006 05:16:50

Previous topic - Next topic

monkey0506

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.

Janik

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.
Play pen and paper D&D? Then try DM Genie - software for Dungeons and Dragons!

Scorpiorus

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;

Radiant


SMF spam blocked by CleanTalk