comp.lang.ada
 help / color / mirror / Atom feed
From: Chris Morgan <mihalis@ix.netcom.com>
Subject: Re: coercing an integer to a string
Date: 1998/11/16
Date: 1998-11-16T00:35:59-06:00	[thread overview]
Message-ID: <87af1s3zvw.fsf@mihalis.ix.netcom.com> (raw)
In-Reply-To: dummy-1611980023110001@dialup-608.hip.cam.org

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1170 bytes --]

dummy@e.mail (Emmanuel M. D�carie) writes:

> Hello, 
> 
> I need 2 functions.
> 
> Function 1 will take for input an integer and will return the number as a
> string.
> 
> Function 2 will reverse this action, i.e. will take a string that contains
> a integer and will return an integer.
> 
> Can anybody suggest me a way to do this, or point me to a faq.
> 
> I'm just starting with Ada, and I can find anything on this in "Ada 95
> From the Beginning" and in "Ada 95 Problem Solving and Program Design.

Think about it a bit. Function 1 requires you to build up a string
piece by piece. Can you work out how to decide how many 1000s, 100s,
10s, units and so on the number contains? Then you would just need to
work out how to join the characters together. 

Similarly the 2nd function - work out what each character means in
terms of numerical value and then add them together. It's not as hard
as it seems.

Cheers,

Chris
p.s. there are some helpful functions in the back of the Ada Language
Reference Manual (findable on the web if you don't have it).
-- 
Chris Morgan <mihalis at ix.netcom.com> 
       Home Web Server -  http://mihalis.dyn.ml.org/index.html




  reply	other threads:[~1998-11-16  0:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-11-16  0:00 coercing an integer to a string Emmanuel M. D�carie
1998-11-16  0:00 ` Chris Morgan [this message]
1998-11-16  0:00   ` John McCabe
1998-11-17  0:00     ` Chris Morgan
1998-11-17  0:00       ` John McCabe
1998-11-18  0:00         ` Emmanuel M. D�carie
1998-11-20  0:00           ` Dale Stanbrough
1998-11-23  0:00             ` Robert I. Eachus
1998-11-23  0:00           ` Chris Morgan
1998-11-16  0:00 ` Tom Moran
1998-11-16  0:00   ` John McCabe
replies disabled

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