lua-users home
lua-l archive

Re: Why do some math functions return -0

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 2010年9月20日, David Kastrup wrote:
> Tony Finch <dot@dotat.at> writes:
> > On 20 Sep 2010, at 09:18, David Kastrup <dak@gnu.org> wrote:
> > > Tony Finch <dot@dotat.at> writes:
> > > >
> > > > It can happen if the rounding mode is towards negative
> > > > infinity.
> > >
> > > Please point out the line in question where this would apply.
> >
> > There are lots of subtractions in the code.
>
> Hogwash.
Have a look at the Lua reference manual:
	Modulo is defined as
		a % b == a - math.floor(a/b)*b
	That is, it is the remainder of a division that rounds the
	quotient towards minus infinity.
Tony.
-- 
f.anthony.n.finch <dot@dotat.at> http://dotat.at/
HUMBER THAMES DOVER WIGHT PORTLAND: NORTH BACKING WEST OR NORTHWEST, 5 TO 7,
DECREASING 4 OR 5, OCCASIONALLY 6 LATER IN HUMBER AND THAMES. MODERATE OR
ROUGH. RAIN THEN FAIR. GOOD.

AltStyle によって変換されたページ (->オリジナル) /