caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Yaron Minsky <yminsky@gmail.com>
To: Markus Mottl <markus@oefai.at>
Cc: Jean-Christophe Filliatre <jean-christophe.filliatre@lri.fr>,
	Caml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Counting bits in a big_int
Date: Sat, 15 May 2004 16:19:04 -0400	[thread overview]
Message-ID: <891bd339040515131939afd837@mail.gmail.com> (raw)
In-Reply-To: <20040515111433.GA32168@fichte.ai.univie.ac.at>

Nice.  The weird thing about the Nat module is that it's completely
undocumented.  Is there any reason to think it wil be stable between
revisions?  For instance, does Xavier's reimplementation have the same
Num module with the same interface as the previous one?

I guess my real question is: why is Nat undocumented?

y

On Sat, 15 May 2004 13:14:33 +0200, Markus Mottl <markus@oefai.at> wrote:
> 
> On Fri, 14 May 2004, Yaron Minsky wrote:
> > Here's the fastest bitcounter I've been able to come up with.  It's
> > about an order of magnitude faster than just counting bit by bit.
> 
> How about this:
> 
> ---------------------------------------------------------------------------
> open Big_int
> open Nat
> 
> let nbits x =
>  let nat = nat_of_big_int (abs_big_int x) in
>  let nwords = num_digits_nat nat 0 (length_nat nat) in
>  Sys.word_size * nwords - num_leading_zero_bits_in_digit nat (nwords - 1)
> ---------------------------------------------------------------------------
> 
> This runs another order of magnitude faster, and it's shorter, too :-)
> 
> Regards,
> Markus
> 
> --
> Markus Mottl          http://www.oefai.at/~markus          markus@oefai.at
>

-------------------
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


  reply	other threads:[~2004-05-15 20:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-12  3:22 Yaron Minsky
2004-05-12  4:19 ` Michael Hoisie
     [not found] ` <16547.8441.559944.112854@gargle.gargle.HOWL>
     [not found]   ` <891bd3390405130427180c36d6@mail.gmail.com>
     [not found]     ` <16547.27869.60461.270873@gargle.gargle.HOWL>
2004-05-15  2:53       ` Yaron Minsky
2004-05-15 11:14         ` Markus Mottl
2004-05-15 20:19           ` Yaron Minsky [this message]
2004-05-16  0:51             ` skaller
2004-05-16  7:30             ` Xavier Leroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=891bd339040515131939afd837@mail.gmail.com \
    --to=yminsky@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=jean-christophe.filliatre@lri.fr \
    --cc=markus@oefai.at \
    --cc=yminsky@cs.cornell.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).