This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]