Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Lupo4u2 on Mon 28/10/2013 09:13:16

Title: compiler error: multiply float
Post by: Lupo4u2 on Mon 28/10/2013 09:13:16
Hey there,

i was just wondering if the following is a known bug or not with the editor/compiler (or a feature?!? :P), cause i didn't find anything related so far in the bug tracker or forum:
 
Code (ags) Select
 
    //---------------------
    // AGS version: v3.2.1
    //---------------------
    float a = 3.0;
    a *= -1.0;    // NOK: parse error at 'a'
    a = a * -1.0; // NOK: invalid use of operator '*'
    a = -1.0 * a;   // OK


took me quite some time to figure out what was blocking my script to compile... :(
Title: Re: compiler error: multiply float
Post by: Crimson Wizard on Mon 28/10/2013 09:27:18
1. AGS does not support *= and /= operators (but does += and -=).
2. AGS does not support this sort of expression:
Code (ags) Select

a = a * -1.0;

where '*' and '-' follow each other. The proper way is to use brackets to distinct two operators:
Code (ags) Select

a = a * (-1.0);
Title: Re: compiler error: multiply float
Post by: Lupo4u2 on Mon 28/10/2013 10:17:55
ah, i see.
makes sense and hopefully i will not run into it again, now i know it. ;-)
thanks for the explanation