Version française
Home     About     Download     Resources     Contact us    
Browse thread
Int64 comparison
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jérémie Dimino <jeremie@d...>
Subject: Re: [Caml-list] Int64 comparison
Le mardi 17 mars 2009 à 08:51 -0400, Elnatan Reisner a écrit :
> Do the polymorphic ordering functions -- (<), (>), etc. -- correspond  
> to the numerical ordering for Int64s and Int32s? I assume so, but I  
> didn't see this specified anywhere.

Yes, int64s and int32s are represented in memory by custom blocks [1],
so there is a specific comparison functions for them.

> If the answer is 'yes', is there a reason I should prefer
> Int64.compare n1 n2 < 0
> to
> n1 < n2
> ?

They may be compiled differently if the compiler does not know that n1
and n2 are of type int32 or int64 in the second case, but the result
will be the same. You can have look at [2], paragraph "Polymorphic
types" for details.

Jérémie

[1] http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html#toc136

[2] http://www.ocaml-tutorial.org/performance_and_profiling