[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Modulo infinity
- From: Tom N Harris <telliamed@...>
- Date: Thu, 03 Apr 2014 20:35:52 -0400
On Monday, March 31, 2014 09:46:14 PM Dan Tull wrote:
> In some cursory checking, they return results that are almost always equal
> (or different only at the 12th decimal place or so) aside from this
> discrepancy around infinity as the second operand. Meanwhile, pow (on the
> very next line in luaconf.h) just delegates to the C level pow function.
a = 100
b = a / 3
print(a/b, a%b, math.fmod(a,b))
This prints "3 0 33.333333333333". I have no idea why, but it breaks the
guarantee that a=floor(a/b)*b+a%b
By that reason, though, it's a bug for N%math.huge to return anything other
than N since 0=floor(N/math.huge)
(Curiously, Python N%float("inf") is NaN on Windows and N on Linux. Oops)
--
tom <telliamed@whoopdedo.org>