*** GMX Spamverdacht *** Re: [fpc-devel] -1 mod 3

Vinzent Höfler JeLlyFish.software at gmx.net
Tue Oct 28 19:03:35 CET 2008


Thaddy wrote:
> Or maybe a new switch: COMPUTATIONALLYWRONG_MATHEMATICALLYCORRECT ON/OFF?
> Although an assumed standard, lot´s of modern calculations depend on a 
> mod being able to assume a negative value.

Conceptually it's just the difference between "modulo" (mod) and 
"remainder" (rem). Some computer languages have distinct operators for 
those:

-- 8< --
     Signed integer division and remainder are defined by the relation:

(5)
        A = (A/B)*B + (A rem B)

(6)
     where (A rem B) has the sign of A and an absolute value less than 
the absolute value of B. Signed integer division satisfies the identity:

(7)
        (-A)/B = -(A/B) = A/(-B)

(8)
     The signed integer modulus operator is defined such that the result 
of A mod B has the sign of B and an absolute value less than the 
absolute value of B; in addition, for some signed integer value N, this 
result satisfies the relation:

(9)
        A = B*N + (A mod B)
-- 8< --

So the "mod" in Delphi/FPC is just called wrong. ;)


Vinzent.



More information about the fpc-devel mailing list