From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p05GYdgH022647 for ; Wed, 5 Jan 2011 17:34:39 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Au0AAEcsJE3RVdg2kGdsb2JhbACDd5Fnjj0IFQEBAQEJCQwHEQQgp3SJPDyCGIRmLoVzAQEDBYEcgzd0BIRohiKGFA X-IronPort-AV: E=Sophos;i="4.60,278,1291590000"; d="scan'208";a="84260194" Received: from mail-qw0-f54.google.com ([209.85.216.54]) by mail4-smtp-sop.national.inria.fr with ESMTP; 05 Jan 2011 17:34:34 +0100 Received: by qwj9 with SMTP id 9so15984230qwj.27 for ; Wed, 05 Jan 2011 08:34:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=u7JJybF/IFjW1+5DyfvjMP9otoepegEUMm4HadDzqrs=; b=xOhctedd5al4yzNnvIeU+WUMOy505zm58ShjinJ0H92kW8b/7k6iPGgURX6azH7i56 h7Qmz1xxlKWcZbgu/dGcucrX2b75ScEdZzzhJeo2eBrn95gxms+USbY+gdr8sxzdTYSk ARG3HPAnbgrbmiIUJSeo+FAByhZ/vn/ODgcqA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=th+jgfai7Hc/mkOiTwNEdJS7ArUR/pgLwOurGGbVx/tI+5uq+X/K1w82YYg9kFo9xv RKZzgpnErLUCzBkYemLre1D/tx0hOH6zJNc5jRofvZm4dRQut3Uut7cm0P12zB3asFtb AfIx8FJrpTH/ooULY6Zzb1sZDHGZZ9AEYH2e0= MIME-Version: 1.0 Received: by 10.229.216.143 with SMTP id hi15mr20396430qcb.27.1294245273426; Wed, 05 Jan 2011 08:34:33 -0800 (PST) Received: by 10.229.106.203 with HTTP; Wed, 5 Jan 2011 08:34:33 -0800 (PST) In-Reply-To: References: Date: Wed, 5 Jan 2011 11:34:33 -0500 Message-ID: From: Niki Yoshiuchi To: Eray Ozkural Cc: caml-list@inria.fr Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p05GYdgH022647 Subject: Re: [Caml-list] Fixed-point arithmetic on 32-bit architectures What range of numbers are you hoping to represent and what operations are you commonly performing on them? If it's possible for you to represent your numbers as 24.8 fixed-point (for example) and you are mostly adding and subtracting, then I would recommend using 32 bit integers and casting to 64 bit for multiplication and division. Alternatively you can try and be clever about your shifting instead of casting (shifting the multiplicand instead of the product, or doing a half shift on each multiplicand, etc). On Wed, Jan 5, 2011 at 11:22 AM, Eray Ozkural wrote: > Hello there, > I'm using fixed-point arithmetic in an algorithm. I am troubled by the > inefficiency of the fixed-point multiplication and division operations on > 32-bit architectures. On the Intel 64-bit architecture, I can use the > Nativeint module and it's quite fast, on 32-bit I had to use the Int64 > module (for the necessary shifts and mul/div's) and I encountered a > significant slowdown, naturally. is there a preferred way of performing > fixed point arithmetic with ocaml on 32-bit architectures that I might be > overlooking? > Best, > -- > Eray Ozkural, PhD candidate.  Comp. Sci. Dept., Bilkent University, Ankara > http://groups.yahoo.com/group/ai-philosophy > >