comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: integers into strings
Date: Thu, 02 Feb 2006 05:48:55 +0000
Date: 2006-02-02T05:48:55+00:00	[thread overview]
Message-ID: <m28xsub9a0.fsf@grendel.local> (raw)
In-Reply-To: 1138851785.180604.32910@g47g2000cwa.googlegroups.com

"isaac2004" <isaac_2004@yahoo.com> writes:

> no im not converting the inputted number into a string im sorting
> the digits of the value into ascending and descending order and then
> making two different numbers out of it one ascending one descending

The input is a string.

A string is an array of characters, so if you can sort an array you
can sort a string. I don't know what the point of this exercise is for
you but some hints on how you might use attributes to help make a
function that sorts a string of arbitrary length are in this ..

   with Ada.Text_IO; use Ada.Text_IO;

   procedure Isaac is
      Input : constant String := "1234";
      Output : String (1 .. Input'Length);
   begin
      for I in Input'Range loop
         Output (Output'Last - (I - Input'First)) := Input (I);
      end loop;
      Put_Line (Output);
   end Isaac;

Once you have a string, you can convert it to an integer using
Integer'Value:

   Result : constant Integer := Integer'Value (Output);



  reply	other threads:[~2006-02-02  5:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-02  1:38 integers into strings isaac_2004
2006-02-02  2:15 ` Jeffrey R. Carter
2006-02-02  3:43   ` isaac2004
2006-02-02  5:48     ` Simon Wright [this message]
2006-02-02 19:32     ` Jeffrey R. Carter
replies disabled

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