From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: help Please
Date: 1999/01/24
Date: 1999-01-24T00:00:00+00:00 [thread overview]
Message-ID: <m3u2xgwa9x.fsf@mheaney.ni.net> (raw)
In-Reply-To: 36ab9be5.2873369@news.ptd.net
rross@postoffice.ptd.net (bob) writes:
> hey, i am a student and i cant seem to figure this out:
> we are to add two integer numbers together , assuming that the
> computer
> doesnt know how to add. for example , you read two integers into an
> array
> of characters each.
> then you add the numbers together in a for loop:
>
> for a in reverse (1..10) loop
> --Z is the 3rd array or result array
> Z(a) := A(a)+B(a)+carry;
>
> something like that, where carry is if you have a sum of more than 10,
> which is decided in an if statement later in the loop
>
> my problem is: we are supposed to use array A and B as type
> characters.
> you cant add two characters and you cant typecast them to integers, so
> how
> do u get the result of the sums into Z?
> any help on this would be greatly appreciated
> thanks in advance
If you want to add two characters together, then just define an operator
to do that:
function "+" (L, R : Character) return Character is ...;
You can't "typecast" a character to integer, like this
... Integer (C) ...
but of course you can convert a character into its underlying integer
representation either by using Unchecked_Conversion or Character'Pos.
next parent reply other threads:[~1999-01-24 0:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <36ab9be5.2873369@news.ptd.net>
1999-01-24 0:00 ` Matthew Heaney [this message]
1999-01-26 0:00 ` help Please Simon Wright
1999-01-26 0:00 ` Steve Kerr
1999-01-26 0:00 ` David C. Hoos, Sr.
1999-01-27 0:00 ` Steve Kerr
1999-01-27 0:00 ` Tucker Taft
2000-05-22 0:00 help please saju sathyan
2000-05-22 0:00 ` Gautier
2000-05-23 0:00 ` saju sathyan
-- strict thread matches above, loose matches on Subject: below --
2001-12-16 15:27 Pierrick
2001-12-16 18:27 ` Patrick Hohmeyer
2001-12-16 19:46 ` Steve Doiel
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox