Inefficiency of `mod'

Frank Heckenbach ih8mj at
Sun Oct 24 16:34:01 CEST 2010

Lennart Thelander wrote:

> I disagree somewhat.
> In this case the '-' is a unary operator, not an additive operator. A unary
> operator should evaluate before any other operator, at least in this case.
> The -10 should evaluate immediately as the simple value it is. Then the mod
> operator is evaluated.
> So you should not have to put any parenthesis around -10 to obtain the
> correct result. 

Well, that's your personal opinion which is shared by C and related
languages, including Borland Pascal.

But Adriaan explicitly asked about standard Pascal which follows the
mathematical convention (see ISO 7185, 6.7.1) where there's no
special priority of unary operators, e.g. in mathematics -2^2 equals
-4, not 4.


Frank Heckenbach, f.heckenbach at,, 7977168E
GPC To-Do list, latest features, fixed bugs:
GPC download signing key: ACB3 79B2 7EB2 B7A7 EFDE  D101 CD02 4C9D 0FE0 E5E8

More information about the Gpc mailing list