comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Integer to String
Date: Thu, 29 Jan 2015 17:51:03 +0000
Date: 2015-01-29T17:51:03+00:00	[thread overview]
Message-ID: <ly4mr9tr08.fsf@pushface.org> (raw)
In-Reply-To: YtednSPAs64J8lfJnZ2dnUU7-ImdnZ2d@giganews.com

montgrimpulo <aghte@hotlinemail.com> writes:

>    num : integer ; char : character ; str : String(1..6);
> begin

>    str:="123456";
>    num:=Integer'Value(str);
>    New_Line(2);Put("num= ");Put(num);
> (20)   str:=Integer'Image(num);

> raised CONSTRAINT_ERROR : itos.adb:20 length check failed.

Integer'Image prefixes the digits of the result with a '-' if the number
is negative and a space if it's positive.

You could just write

   Put (Integer'Image (num));

or

   num := Integer'Value ("123456");
   Put_Line ("str=" & Integer'Image (num));

  reply	other threads:[~2015-01-29 17:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-29 17:36 Integer to String montgrimpulo
2015-01-29 17:51 ` Simon Wright [this message]
2015-01-29 19:16 ` Jeffrey Carter
2015-01-29 20:39 ` Anh Vo
replies disabled

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