[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Integer division in Lua with numbers as longs
- From: ramsdell@... (John D. Ramsdell)
- Date: 17 Apr 2006 20:22:12 -0400
> A user of the patch has suggested to me that Lua's division and
> modulus operator should satisfy the same equation as C's integer
> division and remainder operators.
I see this topic was recently discussed in another thread I happened
not to be following. I concluded that integer division should work as
it does in Python, and changed the patch to define division as
follows.
#define luai_numdiv(a,b) ((a)<0==(b)<0||(a)%(b)==0?(a)/(b):(a)/(b)-1)
John