metaeducation / rebol-issues

6 stars 1 forks source link

Mod returns negative value where both supplied arguments are negative. #1332

Open rebolbot opened 14 years ago

rebolbot commented 14 years ago

Submitted by: PeterWood

Mod returns negative value where both supplied arguments are negative. The absolute value appears to be incorrect.

mod -8 -5 gives the result -8 rather than 3
>> mod -8 -5
== -8

CC - Data [ Version: alpha 94 Type: Bug Platform: All Category: Mezzanine Reproduce: Always Fixed-in:none ]

rebolbot commented 14 years ago

Submitted by: Ladislav

Yes, right, the MOD function works correctly only when the second value is positive.

rebolbot commented 14 years ago

Submitted by: BrianH

Technically, modulus is only defined for positive numbers. Most programming languages extend it to negative numbers as well. Does the behavior of MOD match the behavior that most of these languages follow in this case? If so, we can declare this to be the correct behavior.