From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,INVALID_MSGID, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,99bed60f2de3a39c X-Google-Attributes: gid103376,public From: Chris Morgan Subject: Re: coercing an integer to a string Date: 1998/11/16 Message-ID: <87af1s3zvw.fsf@mihalis.ix.netcom.com>#1/1 X-Deja-AN: 412299361 Sender: cm@mihalis.ix.netcom.com References: Organization: Linux Hackers Unlimited X-NETCOM-Date: Mon Nov 16 12:35:59 AM CST 1998 Newsgroups: comp.lang.ada Date: 1998-11-16T00:35:59-06:00 List-Id: 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 Home Web Server - http://mihalis.dyn.ml.org/index.html