expressions: modulus or modulo operator?
Andreas Albarello
andreas.albarello at TERRITORIUMONLINE.COM
Wed Sep 19 08:26:08 PDT 2007
Michael Schulz wrote:
> When i looked in mapparser.y i found this line:
> 345: math_exp '%' math_exp { $$ = (int)$1 * (int)$3; }
>
> This looks like the modulo operator is defined, but the calculation is
> not modulo.
Michael,
indeed, that isn't modulo nor is it modulus, that's a multiplication of
two truncated values (hence the (int) typecast). And
http://trac.osgeo.org/mapserver/changeset/5151 confirms that line in
mapparser.y is the actual implementation of what was called "modulus
operator" in HISTORY.TXT.
I'd file a bug report about this, since at least it isn't clear what is
meant with "modulus" in this instance. If you need the actual modulo
operator, I'd suggest changing that line to
math_exp '%' math_exp { $$ = (int)$1 % (int)$3; }
and regenerating the parser with yacc -p msyy -d -omapparser.c mapparser.y.
Best regards,
--
--------------------------------------------------------------------
Andreas Albarello
Analysis & SW Development
Territorium Online srl/GmbH
Via Buozzi/Buozzistraße 12 - I 39100 Bolzano/Bozen
email: andreas.albarello at territoriumonline.com
web: www.territoriumonline.com
--------------------------------------------------------------------
More information about the MapServer-users
mailing list