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-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a05:622a:11d3:b0:40b:2fd7:55a8 with SMTP id n19-20020a05622a11d300b0040b2fd755a8mr10563qtk.8.1690674807552; Sat, 29 Jul 2023 16:53:27 -0700 (PDT) X-Received: by 2002:a05:6870:1a81:b0:1ba:7bf5:67cd with SMTP id ef1-20020a0568701a8100b001ba7bf567cdmr7299856oab.11.1690674806965; Sat, 29 Jul 2023 16:53:26 -0700 (PDT) Path: eternal-september.org!news.eternal-september.org!border-1.nntp.ord.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, 29 Jul 2023 16:53:26 -0700 (PDT) In-Reply-To: <5c870602-e55e-4fe5-9f71-d5cf78d163fcn@googlegroups.com> Injection-Info: google-groups.googlegroups.com; posting-host=98.59.238.112; posting-account=oHOvdQoAAACYgyEBjgPNvKFOGxg8pNns NNTP-Posting-Host: 98.59.238.112 References: <4364b66d-97a6-46c4-b11d-382aee086216n@googlegroups.com> <5c870602-e55e-4fe5-9f71-d5cf78d163fcn@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <2a5702b3-dbbc-4255-a4d4-e801f227fed3n@googlegroups.com> Subject: Re: When using the Ada Big_Numbers.Big_Integers package, can the To_String function output be sliced? From: Kenneth Wolcott Injection-Date: Sat, 29 Jul 2023 23:53:27 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:65466 List-Id: On Saturday, July 29, 2023 at 4:49:08=E2=80=AFPM UTC-7, Kenneth Wolcott wro= te: > On Saturday, July 29, 2023 at 4:07:17=E2=80=AFAM UTC-7, AdaMagica wrote:= =20 > > > Powers_of_2 :=3D Powers_of_2 * To_Big_Integer (2);=20 > > With the aspect Integer_Literal, also Powers_of_2 * 2 must work. The at= tributes Integer_Literal, Real_Literal, Put_Image make the new big numbers = nearly work like numeric types (they are not). A difference: The range synt= ax for instance in loops A .. B is illegal. > I understand that the range syntax in loops implies that the loop variabl= e is acting like an enumerated type which is not true for Big_Integers.=20 >=20 > What confused me is that I thought I had to convert the numeric literal (= I'll have to go back and look at the package spec again to get this firmly = understood.=20 >=20 > I have an another question about string slicing: I've tried (obviously in= correctly) to use a variable is one of the slice integers. Can this be done= ?=20 >=20 > Thanks,=20 > Ken Apparently not :-( gnatmake main.adb gcc -c main.adb main.adb:28:67: error: named parameters not permitted for attributes 9 with Ada.Text_IO; use Ada.Text_IO; 10 with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; 11 with Ada.Float_Text_IO; use Ada.Float_Text_IO; 12 with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_= Functions; 13 with Ada.Command_Line; use Ada.Command_Line; 14 15 procedure Main is 16 Substr : String :=3D Argument (1); 17 Nth : Positive :=3D Integer'Value (Argument (2)); 18 I, J : Natural; 19 Temp : Float; 20 begin 21 I :=3D 0; 22 J :=3D 0; 23 loop 24 I :=3D I + 1; 25 exit when I >=3D 10; 26 Temp :=3D 10.0 ** (log (2.0, 10.0) * Float (I)); 27 if I >=3D 4 then 28 if (Float'Image (10.0 ** (log (2.0, 10.0) * Float (I)), Aft = =3D> 0, Exp =3D> 0) (1 .. Substr'Length) =3D Substr then 29 J :=3D J + 1; 30 if J =3D Nth then 31 Put (I, 0); 32 New_Line; 33 exit; 34 end if; 35 end if; 36 end if; 37 end loop; 38 end Main; Thanks, Ken