From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.36.103.203 with SMTP id u194mr30261itc.0.1519948241540; Thu, 01 Mar 2018 15:50:41 -0800 (PST) X-Received: by 10.157.22.195 with SMTP id s3mr169890ots.13.1519948241402; Thu, 01 Mar 2018 15:50:41 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.unit0.net!peer01.am4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!e10no79759itf.0!news-out.google.com!a25ni94itj.0!nntp.google.com!w142no78282ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 1 Mar 2018 15:50:41 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:191:8303:2100:7466:f44c:da21:40b1; posting-account=fdRd8woAAADTIlxCu9FgvDrUK4wPzvy3 NNTP-Posting-Host: 2601:191:8303:2100:7466:f44c:da21:40b1 References: <421d1598-68d7-4d0b-b596-6e9c59cf865c@googlegroups.com> <877eqxe7u8.fsf@nightsong.com> <87muzsz6s2.fsf@nightsong.com> <628c3bba-6c0d-495b-be2f-e6ed3ef3418f@googlegroups.com> <40f38dfc-d456-4c7c-a65b-8990483af0a3@googlegroups.com> <73e69dd3-3195-48c7-9b9b-f1a4bb7d6fde@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <83612ef4-3482-48cd-9c3a-a54f19b1b976@googlegroups.com> Subject: Re: 64-bit unsigned integer? From: Robert Eachus Injection-Date: Thu, 01 Mar 2018 23:50:41 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Body-CRC: 778516343 X-Received-Bytes: 3509 Xref: reader02.eternal-september.org comp.lang.ada:50781 Date: 2018-03-01T15:50:41-08:00 List-Id: On Thursday, March 1, 2018 at 4:15:28 PM UTC-5, Dmitry A. Kazakov wrote: > Bounded numbers will be a generic package thus you will not be able to=20 > intermix differently bounded numbers even if they are semantically same.= =20 > You will not be able to convert between such types. You will have no=20 > literals, no universal integer expressions, no way to pass it to a=20 > generic numeric package, no way to have it as discriminant (large=20 > discriminants are useful in some cases) etc. Try this: type Bignum_Value is array(Long_Integer range <>) of Long_Integer; type Access_Bignum is access Bignum_Value; Default_Max_Size: Long_Integer; type Bounded_Bignum (Size: Long_Integer :=3D 0) is record case Size is=20 when 0..Default_Max_Size =3D> Bounded_Value: Bignum_Value(1..Default_Max_Size); when others =3D> Access_Bignum; end case; end record; Hide this all as appropriate, in a private part, and define the operations.= Overflow is handled by switching representations, and the Default_Max_Siz= e can be tuned by the user for best results in his or her program. Well, t= o be honest overflow can happen. If Long_Integer is 64 bits, then you will= run out of memory long before you hit that limit. Even if the computer su= pports full 64-bit virtual memory, and you have the disk space, the type sp= ecified here should support 2**67 bytes in one value. Mathematicians worry= about things like this, so you might want to have an machine attribute of = the number of bits of the largest value that can be crammed into (virtual) = memory.