lua-users home
lua-l archive

Re: My wish list

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


On 03/16/2012 07:51 PM, Egor Skriptunoff wrote:
2)
Frequently both quotient and remainder are needed.
Let % operator returns pair of values:
a % b == a-floor(a/b)*b, floor(a/b)
The argument for this is that some architectures have a fast divmod implementation. On the other hand, you could do this:
function divmod(q,r)
 local i,f = math.modf(q/r)
 return i, f*r
end
--
- tom
telliamed@whoopdedo.org

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