* Int64 comparison
@ 2009-03-17 12:51 Elnatan Reisner
2009-03-17 13:12 ` [Caml-list] " Till Varoquaux
2009-03-17 15:13 ` Jérémie Dimino
0 siblings, 2 replies; 3+ messages in thread
From: Elnatan Reisner @ 2009-03-17 12:51 UTC (permalink / raw)
To: Caml Mailing List
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.
If the answer is 'yes', is there a reason I should prefer
Int64.compare n1 n2 < 0
to
n1 < n2
? If there's no specific reason the first is better (and I don't see
why it would be), I definitely prefer the second.
-Elnatan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Int64 comparison
2009-03-17 12:51 Int64 comparison Elnatan Reisner
@ 2009-03-17 13:12 ` Till Varoquaux
2009-03-17 15:13 ` Jérémie Dimino
1 sibling, 0 replies; 3+ messages in thread
From: Till Varoquaux @ 2009-03-17 13:12 UTC (permalink / raw)
To: Elnatan Reisner; +Cc: Caml Mailing List
Taken from Int64.ml:
let compare (x: t) (y: t) = Pervasives.compare x y
compare seems to be there for functor applications (e.g. Set.Make
needs it). I would use standard comparison; it should be exactly the
same except it will be more legible and might be a tad faster.
Till
On Tue, Mar 17, 2009 at 8:51 AM, Elnatan Reisner <elnatan@cs.umd.edu> wrote:
> 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.
>
> If the answer is 'yes', is there a reason I should prefer
> Int64.compare n1 n2 < 0
> to
> n1 < n2
> ? If there's no specific reason the first is better (and I don't see why it
> would be), I definitely prefer the second.
> -Elnatan
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Int64 comparison
2009-03-17 12:51 Int64 comparison Elnatan Reisner
2009-03-17 13:12 ` [Caml-list] " Till Varoquaux
@ 2009-03-17 15:13 ` Jérémie Dimino
1 sibling, 0 replies; 3+ messages in thread
From: Jérémie Dimino @ 2009-03-17 15:13 UTC (permalink / raw)
To: Elnatan Reisner; +Cc: Caml Mailing List
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-03-17 15:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-17 12:51 Int64 comparison Elnatan Reisner
2009-03-17 13:12 ` [Caml-list] " Till Varoquaux
2009-03-17 15:13 ` Jérémie Dimino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox