This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: Efficient integer division (quotient) and modulo
- From: Rob Hunter <rhunter at mercedsystems dot com>
- To: Rob Hunter <rhunter at mercedsystems dot com>, <kawa at sources dot redhat dot com>
- Date: Tue, 03 Jul 2007 10:40:08 -0700
- Subject: Re: Efficient integer division (quotient) and modulo
Note that, according to Jode,
(define (fast-/ (a :: <int>) (b :: <int>))
(/ a b))
compiles to
public static gnu.math.RatNum fast$Mn$Sl(int a, int b) {
return gnu.math.RatNum.divide(IntNum.make(a), IntNum.make(b));
}
which isn't the "/" sign compilation that I'm looking for (nor the
semantics, actually).
--rob
On 7/3/07 8:40 AM, "Rob Hunter" <rhunter@mercedsystems.com> wrote:
> Does anyone know how, in Kawa, I can write something like
>
> (/ a b)
>
> and
>
> (modulo a b)
>
> (where a and b are <int>), and have it compile to efficient bytecode? I.e.,
> the bytecode that would be generated by
>
> int a = ...;
> int b = ...;
> int c = a / b;
> int d = a % b;
>
> Thanks for any advice,
>
> Rob
>