Re: very simple questions about integer division

  • From: Francesco Abbate <>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Fri, 31 Aug 2012 14:18:27 +0200

2012/8/31 Mike Pall <mike-1208@xxxxxxxxxx>:
> Only adding a function to the library doesn't help. You'll need to
> teach the compiler how to handle this function and change all of
> the backends to implement this function (unless it can be constructed
> from existing IR instructions).

Hi Mike, all,

thank you for your answer. I see from your feedback that the problem
really exists even if this is certainly not a big matter.

Based on your suggestion I propose to add the "div" function to the
math module. It should returns and quotient and the remainder, or may
be only the quotient, I accept suggestions.


thank you for the reference, the article is very accurate and
complete. It is amazing that you have a whole article on the subject
of div/mod implementation. In any case I appreciate better now some
subtleties about the possible choice of the quotient and remainder and
what the CPU "idiv" instruction really does.


I understand that this is a secondary matter for you to bother to
implement it but I think that it would be nice to fill this gap. After
all the Intel guys bothered to add a specific instruction for this
operation :-)

I volunteer to implement it in LuaJIT but I would need some help to
get started doing this job.


Other related posts: