comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: From_string(Arg : String) return Big_Integer
Date: Sun, 10 Jan 2021 00:40:17 +0100	[thread overview]
Message-ID: <rtdet1$k5u$1@dont-email.me> (raw)
In-Reply-To: <5ffa2a7b$0$19459$426a74cc@news.free.fr>

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

  reply	other threads:[~2021-01-09 23:40 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
2021-01-09 20:11   ` soren rundgren
2021-01-09 22:13     ` DrPi
2021-01-09 23:40       ` Jeffrey R. Carter [this message]
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