From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: From_string(Arg : String) return Big_Integer Date: Sun, 10 Jan 2021 00:40:17 +0100 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <5126648c-215e-4d9e-bdd9-82fa5b510896n@googlegroups.com> <5ffa2a7b$0$19459$426a74cc@news.free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sat, 9 Jan 2021 23:40:17 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="bb432b5301ac52e8369f536f1a5ea809"; logging-data="20670"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+SxlP9iGNXEFYiQJX9syBNhysPPWmpHiE=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 Cancel-Lock: sha1:AqWgyaqQ2VaWJbq2Nbnq1WhLY4A= In-Reply-To: <5ffa2a7b$0$19459$426a74cc@news.free.fr> Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:61086 List-Id: On 1/9/21 11:13 PM, DrPi wrote: > >    function Int_From_String (Str : String) return Integer is >       Num : Integer := 0; >    begin >       for C of Str loop >          Num := (Num * 10) + Integer'Value((1 => C)); >       end loop; > >       return Num; >    end Int_From_String; > > Notes : > - It does not manage the sign (like the function you designed). There's a fairly complete Value function for unbounded integers in PragmARC.Unbounded_Numbers.Integers at https://github.com/jrcarter/PragmARC It handles negative values and based values. -- Jeff Carter "Help! Help! I'm being repressed!" Monty Python & the Holy Grail 67