Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Does Caml have slow arithmetics ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: David Haguenauer <David.Haguenauer@i...>
Subject: Re: [Caml-list] Does Caml have slow arithmetics ?
On 2004-07-07 14:32:56 Wed, Diego Olivier Fernandez Pons wrote:
> > In principle yes, because int values are represented as tagged
> > (31bits) ints (with the LSB set to 1). So conversion is a shift
> > followed by an addition (or viceversa).
> 
> Subsidiary question : why LSB instead of MSB ? I thought it would be
> simpler to let the computations silently overflow and correct when
> necessary the tag bit.

Xavier Leroy's report about the ZINC experiment gives a good
rationale:

    4.2.1 Unallocated objects

    The only kind of unallocated (unboxed) objects is small
    integers. As the heap contains only 32-bit words, all pointers in
    the heap are 32-bit aligned, so their low-order bits are always
    00. Integers are therefore encoded with a 1 as low-order bit:
    [...]

(http://pauillac.inria.fr/~xleroy/publi/ZINC.ps.gz)

-- 
David Haguenauer

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners