From: soren rundgren <soren.m.rundgren@gmail.com>
Subject: Re: From_string(Arg : String) return Big_Integer
Date: Sat, 9 Jan 2021 12:09:50 -0800 (PST) [thread overview]
Message-ID: <4b233620-491c-4830-b4c7-0f53c93f0e81n@googlegroups.com> (raw)
In-Reply-To: <fc7db0da-59f3-4b50-be41-98b8f3eb8ca5n@googlegroups.com>
lördag 9 januari 2021 kl. 18:00:36 UTC+1 skrev AdaMagica:
> Since Ada 202X is not yet released, this package is not yet fully implemented. (I had a conversation with AdaCore about a similar case a year ago.)
I managed to make a very baic solution by creating my own:
function My_From_String(S : String) return Big_Integer is
sum : Big_Integer := 0;
Len : constant Integer := S'Length;
i : Integer := 1;
begin
-- Ada.Text_IO.Put_Line("My_From_String.S = " & S);
while i <= Len loop
case S(i) is -- i = Len : Len - Len = 0,
-- i = 1 : Len - 1
when '1' => sum := sum + 1*10**(Len - i);
when '2' => sum := sum + 2*10**(Len - i);
when '3' => sum := sum + 3*10**(Len - i);
when '4' => sum := sum + 4*10**(Len - i);
when '5' => sum := sum + 5*10**(Len - i);
when '6' => sum := sum + 6*10**(Len - i);
when '7' => sum := sum + 7*10**(Len - i);
when '8' => sum := sum + 8*10**(Len - i);
when '9' => sum := sum + 9*10**(Len - i);
when others => null;
end case;
i := i + 1;
end loop;
return sum;
end My_From_String;
next prev parent reply other threads:[~2021-01-09 20:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-09 15:16 From_string(Arg : String) return Big_Integer soren rundgren
2021-01-09 17:00 ` AdaMagica
2021-01-09 20:09 ` soren rundgren
2021-01-09 20:09 ` soren rundgren [this message]
2021-01-09 20:11 ` soren rundgren
2021-01-09 22:13 ` DrPi
2021-01-09 23:40 ` Jeffrey R. Carter
2021-01-10 9:46 ` Dmitry A. Kazakov
2021-01-10 15:48 ` DrPi
2021-01-10 16:02 ` Dmitry A. Kazakov
2021-01-10 16:33 ` DrPi
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox