From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Thomas Braibant <thomas.braibant@gmail.com>
Cc: OCaML Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Arbitrary precision unsigned integers
Date: Tue, 20 May 2014 17:29:01 +0200 [thread overview]
Message-ID: <CAH=h3gEAGxAnyQAYiyXFiFb62om3E7hxVANEd8183iGxAAcqhQ@mail.gmail.com> (raw)
In-Reply-To: <CAHR=VkxSM+YiQbRFkVUSQqCa98pEUbF0GaU7RrzHX7if5-Ls1Q@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1064 bytes --]
Hi Thomas,
In a pinch, you can use Zarith and follow each arithmetic operation by a
Z.extract or Z.signed_extract operation to normalize the result to the
desired range (N-bit unsigned or N-bit signed). It's not as fast as it
could be, but should be reasonably efficient.
- Xavier Leroy
2014-05-20 17:18 GMT+02:00 Thomas Braibant <thomas.braibant@gmail.com>:
> Hi list,
>
> I wonder if there is a publicly available library that implements
> arbitrary precision (un)signed integers. I could not find anything
> relevant with Google, nor on Opam.
>
> By arbitrary, I mean that I want to implement e.g., 43 bits unsigned
> arithmetic, and have the right overflow behaviors. I know of zarith
> which seems to implement arbitrary precision in the sense that the
> precision of the numbers grows as needed.
>
> Best,
> Thomas
>
> --
> Caml-list mailing list. Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>
[-- Attachment #2: Type: text/html, Size: 1766 bytes --]
next prev parent reply other threads:[~2014-05-20 15:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-20 15:18 Thomas Braibant
2014-05-20 15:29 ` Xavier Leroy [this message]
2014-05-20 15:33 ` Thomas Braibant
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='CAH=h3gEAGxAnyQAYiyXFiFb62om3E7hxVANEd8183iGxAAcqhQ@mail.gmail.com' \
--to=xavier.leroy@inria.fr \
--cc=caml-list@inria.fr \
--cc=thomas.braibant@gmail.com \
/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