compiler error: multiply float

Started by Lupo4u2, Mon 28/10/2013 09:13:16

Previous topic - Next topic

Lupo4u2

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
  
    //---------------------
    // 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... :(

Crimson Wizard

1. AGS does not support *= and /= operators (but does += and -=).
2. AGS does not support this sort of expression:
Code: ags

a = a * -1.0;

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

a = a * (-1.0);

Lupo4u2

ah, i see.
makes sense and hopefully i will not run into it again, now i know it. ;-)
thanks for the explanation

SMF spam blocked by CleanTalk