caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Arbitrary precision unsigned integers
@ 2014-05-20 15:18 Thomas Braibant
  2014-05-20 15:29 ` Xavier Leroy
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Braibant @ 2014-05-20 15:18 UTC (permalink / raw)
  To: OCaML Mailing List

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Arbitrary precision unsigned integers
  2014-05-20 15:18 [Caml-list] Arbitrary precision unsigned integers Thomas Braibant
@ 2014-05-20 15:29 ` Xavier Leroy
  2014-05-20 15:33   ` Thomas Braibant
  0 siblings, 1 reply; 3+ messages in thread
From: Xavier Leroy @ 2014-05-20 15:29 UTC (permalink / raw)
  To: Thomas Braibant; +Cc: OCaML Mailing List

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Arbitrary precision unsigned integers
  2014-05-20 15:29 ` Xavier Leroy
@ 2014-05-20 15:33   ` Thomas Braibant
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Braibant @ 2014-05-20 15:33 UTC (permalink / raw)
  To: Xavier Leroy; +Cc: OCaML Mailing List

Thanks for the quick reply. I guess I will do exactly that and release
the wrapper library.


On Tue, May 20, 2014 at 4:29 PM, Xavier Leroy <Xavier.Leroy@inria.fr> wrote:
> 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
>>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-05-20 15:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-20 15:18 [Caml-list] Arbitrary precision unsigned integers Thomas Braibant
2014-05-20 15:29 ` Xavier Leroy
2014-05-20 15:33   ` Thomas Braibant

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