comp.lang.ada
 help / color / mirror / Atom feed
From: "Rego, P." <pvrego@gmail.com>
Subject: Re: AVR Usart send number string with no 'Image
Date: Thu, 25 Apr 2013 19:28:49 -0700 (PDT)
Date: 2013-04-25T19:28:49-07:00	[thread overview]
Message-ID: <7bb4c21a-be68-433e-a517-484798a8a687@googlegroups.com> (raw)
In-Reply-To: <508e7264-46c3-4c53-94e6-6bb427fb3908@googlegroups.com>

I tried this, but the compiler pointed that I could not use the second stack, so this recursion is not allowed.

On Thursday, April 25, 2013 7:55:38 AM UTC-3, Rego, P. wrote:
> On Wednesday, April 24, 2013 11:03:25 PM UTC-3, Shark8 wrote:
> 
> > declare
> 
> > 	Subtype Digit is Character Range '0'..'9';
> 
> > 	Function To_String( Input : Interfaces.Unsigned_8 ) Return String is
> 
> > 	    Subtype Digital is Interfaces.Unsigned_8 Range 0..9;
> 
> > 	begin
> 
> > 	    if Input in Digital then
> 
> > 		Return (1 => Digit'Val( Natural(Input) + Character'Pos('0') ));
> 
> > 	    else
> 
> > 		declare
> 
> > 		    Use Type Interfaces.Unsigned_8;
> 
> > 		    D2 : Constant Interfaces.Unsigned_8:= Input / 10;
> 
> > 		    D1 : Constant Interfaces.Unsigned_8:= Input mod 10;
> 
> > 		begin
> 
> > 		    Return To_String(D2) & To_String(D1);
> 
> > 		end;
> 
> > 	    end if;
> 
> > 	end To_String;
> 
> > 	Subtype Byte_Range is Integer range 0..255;
> 
> > 	X : Integer := 4;
> 
> >     begin
> 
> > 	While X in byte_range loop
> 
> > 	    Ada.Text_IO.Put_Line( To_String( Interfaces.Unsigned_8(X) ) );
> 
> > 	    X:= X*2;
> 
> > 	end loop;
> 
> >     end;
> 
> 
> 
> Thanks Shark8, much interesting your solution.




  reply	other threads:[~2013-04-26  2:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-25  1:27 AVR Usart send number string with no 'Image Rego, P.
2013-04-25  2:03 ` Shark8
2013-04-25 10:55   ` Rego, P.
2013-04-26  2:28     ` Rego, P. [this message]
2013-04-26  5:50       ` Simon Wright
2013-04-30  2:58         ` Rego, P.
2013-04-26 14:52       ` Shark8
2013-04-26 21:10         ` Shark8
2013-04-30  3:00           ` Rego, P.
2013-04-25  4:54 ` rrr.eee.27
2013-04-25 10:58   ` Rego, P.
2013-05-01 20:35 ` Rego, P.
2013-05-01 21:00   ` Simon Wright
2013-05-01 22:07     ` Rego, P.
2013-05-01 22:30       ` Jeffrey Carter
2013-05-01 22:46         ` Rego, P.
2013-05-01 23:29       ` Dennis Lee Bieber
2013-05-01 22:32   ` Shark8
2013-05-01 23:00     ` Rego, P.
2013-05-01 23:09       ` Shark8
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox