From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.9 required=3.0 tests=BAYES_00,NICE_REPLY_A autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits? Date: Wed, 22 Dec 2021 22:43:49 +0200 Organization: Tidorum Ltd Message-ID: References: <304dcae2-8b20-43ff-8769-32fa06d4dc10n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net LLSbcYEw3fHXp2xPcdO//wk1rmed7fuvBamKw9gYYYPP9bcukR Cancel-Lock: sha1:ORfoDALG2Rd7GGWzliNcHXEF72s= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:63250 List-Id: On 2021-12-22 21:26, Mark Lorenzen wrote: > On Wednesday, December 22, 2021 at 6:27:57 PM UTC+1, Michael Ferguson > wrote: >> On Wednesday, December 22, 2021 at 11:02:03 AM UTC-6, Luke A. Guest >> wrote: >>> On 22/12/2021 05:57, Michael Ferguson wrote: >>>> I just started using the Big_Integer library that is a part of >>>> the 202X version of ADA. >>>> >>>> It is repeatedly described as an "arbitrary precision library" >>>> that has user defined implementation. >>>> >>>> I was under the impression that this library would be able to >>>> infinitely calculate numbers of any length, but there is >>>> clearly a default limit of 300 digits. >>> What are you doing that requires that number of digits? >> I am working on ProjectEuler.net problem number 48. >> >> The questions asks you to sum the numbers n^n for (2 <= n <= 1000) >> and determine what the last ten digits of this number are. > > Interesting. Assume that the problem is related to the maximum size > of lexical elements, can't you then use the "rem" function from > Big_Integers to determine the last 10 digits e.g. by something like > this Last_10_Digits = My_Very_Large_Number rem To_Big_Integer(1) ** > 10? You no doubt meant To_Big_Integer (10), not To_Big_Integer(1). But it should be possible to write directly "... rem 10_000_000_000", and even if that constant is too large for the Integer type, because Big_Integer has the Integer_Literal aspect (assuming GNAT already implements it).