[Gambas-user] Ambiguous expression using \ integer divide

Benoît Minisini benoit.minisini at gambas-basic.org
Sat Nov 11 13:25:11 CET 2023


Le 10/11/2023 à 17:03, Brian G a écrit :
> Why does this expression work
> 
>   ? eval("15393 / 1000 * 1000 + 14")
> 15407
> 
> and this one fail :
> 
>   ? eval("15393 \\ 1000 * 1000 + 14")
> error:Ambiguous expression. Please use brackets
> 
> ? eval("(15393 \\ 1000) * 1000 + 14")
> 15014
> 
> Should not \ and / have the same precedence in an expression except 
> using integer math rather than floating point?
> 

Mmm... Maybe. I added this warning when you mix comparison operators or 
integer-only operators with integer/float operators, so that you are 
sure of what you are doing.

Regards,

-- 
Benoît Minisini.



More information about the User mailing list