[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Modulo infinity
- From: Dirk Laurie <dirk.laurie@...>
- Date: Wed, 2 Apr 2014 18:19:39 +0200
2014-04-02 17:31 GMT+02:00 Dan Tull <dtull@adobe.com>:
> That's actually a bit bizarre since -5 % 3 in C is -2,
> so now Lua's mod also diverges from C behavior, too.
In Lua, the result of x%y has the same sign as y.
In Pari-GP (a number theory package) x%y is always positive.
I don't think there is any standard here. At least Lua documents
it in the manual:
Modulo is defined as the remainder of a division that rounds
the quotient towards minus infinite (floor).
>> So in C the two things are totally different.
> Is there a case where double values that happen to contain
> integer values (no fractional portion) produces a different
> result than % would, though?
Can't see why that could happen.