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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:a05:620a:546:: with SMTP id o6mr9861232qko.269.1610223120134; Sat, 09 Jan 2021 12:12:00 -0800 (PST) X-Received: by 2002:a25:dc7:: with SMTP id 190mr14309187ybn.73.1610223120001; Sat, 09 Jan 2021 12:12:00 -0800 (PST) Path: eternal-september.org!reader02.eternal-september.org!feeder1.feed.usenet.farm!feed.usenet.farm!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 9 Jan 2021 12:11:59 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=217.208.188.133; posting-account=az-JeQkAAADr9cslZlAur-9M8pXwUKdi NNTP-Posting-Host: 217.208.188.133 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <5126648c-215e-4d9e-bdd9-82fa5b510896n@googlegroups.com> Subject: Re: From_string(Arg : String) return Big_Integer From: soren rundgren Injection-Date: Sat, 09 Jan 2021 20:12:00 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:61084 List-Id: l=C3=B6rdag 9 januari 2021 kl. 18:00:36 UTC+1 skrev AdaMagica: > Since Ada 202X is not yet released, this package is not yet fully impleme= nted. (I had a conversation with AdaCore about a similar case a year ago.) I managed to make a very basic solution by creating my own: function My_From_String(S : String) return Big_Integer is sum : Big_Integer :=3D 0; Len : constant Integer :=3D S'Length; i : Integer :=3D 1; begin -- Ada.Text_IO.Put_Line("My_From_String.S =3D " & S); while i <=3D Len loop case S(i) is -- i =3D Len : Len - Len =3D 0, -- i =3D 1 : Len - 1 when '1' =3D> sum :=3D sum + 1*10**(Len - i); when '2' =3D> sum :=3D sum + 2*10**(Len - i); when '3' =3D> sum :=3D sum + 3*10**(Len - i); when '4' =3D> sum :=3D sum + 4*10**(Len - i); when '5' =3D> sum :=3D sum + 5*10**(Len - i); when '6' =3D> sum :=3D sum + 6*10**(Len - i); when '7' =3D> sum :=3D sum + 7*10**(Len - i); when '8' =3D> sum :=3D sum + 8*10**(Len - i); when '9' =3D> sum :=3D sum + 9*10**(Len - i); when others =3D> null; end case; i :=3D i + 1; end loop; return sum; end My_From_String;