From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id B3A187ED9B for ; Tue, 20 May 2014 17:29:33 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of xavier.leroy@gmail.com) identity=pra; client-ip=209.85.192.42; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="xavier.leroy@gmail.com"; x-sender="xavier.leroy@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of xavier.leroy@gmail.com designates 209.85.192.42 as permitted sender) identity=mailfrom; client-ip=209.85.192.42; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="xavier.leroy@gmail.com"; x-sender="xavier.leroy@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-qg0-f42.google.com) identity=helo; client-ip=209.85.192.42; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="xavier.leroy@gmail.com"; x-sender="postmaster@mail-qg0-f42.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ah8BAGFze1PRVcAqlGdsb2JhbABZg1dYgmmpNIEHjXWIfYEUCBYOAQEBAQcLCwkSKoIlAQEEASMdARIbCwEDAQsBBQUEBxodAgIhARIBBQEKEgYTCAqIGwMJCA2iWYwRhFKZMScDCoYvEQEFDIwtghGDAIFLBIReAgOTEYF0gT2LcoQAGCmBaYMBOw X-IPAS-Result: Ah8BAGFze1PRVcAqlGdsb2JhbABZg1dYgmmpNIEHjXWIfYEUCBYOAQEBAQcLCwkSKoIlAQEEASMdARIbCwEDAQsBBQUEBxodAgIhARIBBQEKEgYTCAqIGwMJCA2iWYwRhFKZMScDCoYvEQEFDIwtghGDAIFLBIReAgOTEYF0gT2LcoQAGCmBaYMBOw X-IronPort-AV: E=Sophos;i="4.98,874,1392159600"; d="scan'208";a="62844081" Received: from mail-qg0-f42.google.com ([209.85.192.42]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 20 May 2014 17:29:33 +0200 Received: by mail-qg0-f42.google.com with SMTP id q107so1023486qgd.1 for ; Tue, 20 May 2014 08:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=h4WU8IyVgipwb7Q/YqHWQIomYebB+9nEi7XKMqDErXU=; b=uo0kn0ES5mxXl5pmCu8jzo5RiR7Poe2M0tPSqSgQBbNBRK61E0qTPhrUvFrgvBJtHD 6aXAjegLHS8W71c2E0qYU9cbvudz5N0PqJBuWaO5TS7Iu0tH69m2qS0NpEADfzIcWeCc 80IgFya3tJnOBGsB+pROAuSW581I/90zMzLaK3I5A9ZMOEqJQ4EE31q9K/wz7u1Tlgpm lmNFA20QwU3QjgDQusQbr9zoAMkafZWQgJkz7pK2wkohpPeFQn/UnSZOBACN2TuqcBts V6loocYqn96c16sHeocCTo+qOAVAk+3Ypp8Mpxaj8FoU2iPdNHd0Iwg1SS/6c0TuzRZ4 1Aaw== X-Received: by 10.224.115.135 with SMTP id i7mr57785930qaq.50.1400599771986; Tue, 20 May 2014 08:29:31 -0700 (PDT) MIME-Version: 1.0 Sender: xavier.leroy@gmail.com Received: by 10.224.193.196 with HTTP; Tue, 20 May 2014 08:29:01 -0700 (PDT) In-Reply-To: References: From: Xavier Leroy Date: Tue, 20 May 2014 17:29:01 +0200 X-Google-Sender-Auth: Qg-khK7LmUN7HxKC3Slg4b2gmzE Message-ID: To: Thomas Braibant Cc: OCaML Mailing List Content-Type: multipart/alternative; boundary=047d7bdcaa8ce1dc0e04f9d68bdb Subject: Re: [Caml-list] Arbitrary precision unsigned integers --047d7bdcaa8ce1dc0e04f9d68bdb Content-Type: text/plain; charset=UTF-8 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 : > 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 > > --047d7bdcaa8ce1dc0e04f9d68bdb Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Thomas,

In a pinch, you can use = Zarith and=20 follow each arithmetic operation by a Z.extract or Z.signed_extract=20 operation to normalize the result to the desired range (N-bit unsigned=20 or N-bit signed).=C2=A0 It's not as fast as it could be, but should be= =20 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. =C2=A0Subscription management and archives:
ht= tps://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


--047d7bdcaa8ce1dc0e04f9d68bdb--