• Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!

Question - Code About Macros holding a simple operation

I've just scratch my head around a weird issue coming from macro and brackets to find out that it may not be weird at all, but I would like a confirmation.

Doing this :
Code:
#macro val 5/2

v = 10 / val
will return v = 1

but adding brackets to the division held in the macro :
Code:
#macro val (5 / 2)

v = 10 / val
will result v = 2

I guess that's the expected behavior as the documentation give the example of having a random blending color each time the macro is called :
Code:
#macro col make_colour_hsv(irandom(255), 255, 255)


But well, in order to be sure ...
 

TsukaYuriko

Q&A Spawn Camper
Forum Staff
Moderator
Macros are full-text search and replace. Any occurrence of the macro will be substituted with its value, and any evaluations will be done in place. If you want it to have the value of 5 / 2 (2.5), you have to put parentheses around it, as other operators may take precedence otherwise if you use it in a formula.
 
Top