lua-users home
lua-l archive

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


I have pondered the same problem. Something like 

a, b = math.div(number, divisor)

would be handy in the math library. Having metatmethod support is
another story.


On Tue, 28 Dec 2004 21:47:17 +0200, Asko Kauppi <asko.kauppi@sci.fi> wrote:
> 
> Was trying to make a/b return both integer divident and modulo, but it
> seems these metamethod tricks cannot return more than the return values
> they 'normally' would.  Is this by chance of by design?  I think it
> would be neat to have integer division provide both:
> 
>         a= b/c          -- just divident, if either 'b', 'c' or both are int32 userdata
>         a,d= b/c        -- getting both divident & modulo at once.
> 
> -ak
> 
>