Page 1 of 1

User law - "int" symbol

Posted: Fri Apr 28, 2023 1:53 pm
by lorenzo.iron
I was trying to use the "int" symbol as a floor function (as mentioned in the used guide).
I tried to use the function like, for example, "x=int(1.5)" to return "x=1" but I got the following message from the Expression Editor:
In function ‘cs_meg_boundary_function’: expected expression before ‘int’'

What is the mistake?
Is it maybe only usable as an "int" type definition like "int x = 1"? (but in the guide it is listed like a function)

Have you got any working example of the correct usage of "int" as a function?

Thank you in advance.
Lorenzo

Re: User law - "int" symbol

Posted: Sat Apr 29, 2023 10:28 am
by Yvan Fournier
Hello,

If the user guide mentions int(), this is an error and we need to update this....

The code snippets defined in the GUI formulas are inserted into C code, so if you want to conver a variable x to an integer, you can use the C casting method:
x =(int)1.5;

Best regards,

Yvan