Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-03

modulo of negative dividend

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martín Marqués

I'm checking the mod binary operator, and I found out that if the dividend is negative, it gives a negative result. AFAIK, mod gives an integer between 0 and d-1, where d is the divisor.

Isn't this the right behavior?

Martín Marqués select 'martin.marques' || '@' || 'gmail.com' DBA, Programador, Administrador

Reply by email

Flávio Etrusco
to Martín Marqués

2010/3/13 Martín Marqués :

Show quoted text 8 lines
I'm checking the mod binary operator, and I found out that if the dividend is negative, it gives a negative result. AFAIK, mod gives an integer between 0 and d-1, where d is the divisor. Isn't this the right behavior? -- Martín Marqués

This is the mathematical definition of modulus, but all programming languages implement the same behavior as the one of FPC.

Best regards,
Flávio

Reply by email

Adriaan van Os
to Flávio Etrusco
Flávio Etrusco wrote 12 lines
2010/3/13 Martín Marqués : > I'm checking the mod binary operator, and I found out that if the > dividend is negative, it gives a negative result. AFAIK, mod gives an > integer between 0 and d-1, where d is the divisor. > > Isn't this the right behavior? > > -- > Martín Marqués This is the mathematical definition of modulus, but all programming languages implement the same behavior as the one of FPC.

Not really <http://www2.gnu-pascal.de/crystal/gpc/en/mail7597.html>.

Regards,

Adriaan van Os

Reply by email