comp.lang.ada
 help / color / mirror / Atom feed
* Re: ada help please
       [not found] <36ab9c3f.2963059@news.ptd.net>
@ 1999-01-25  0:00 ` Anthony E. Glover
  1999-01-26  0:00 ` Tom Moran
  1999-02-01  0:00 ` Nick Roberts
  2 siblings, 0 replies; 4+ messages in thread
From: Anthony E. Glover @ 1999-01-25  0:00 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 359 bytes --]

bob wrote:

> 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?

You can't typecast them, but you can use Ada attributes.  I don't have
an Ada book handy, but look for integer attributes that take characters.

Tony

[-- Attachment #2: Card for Anthony E. Glover --]
[-- Type: text/x-vcard, Size: 274 bytes --]

begin:          vcard
fn:             Anthony E. Glover
n:              Glover;Anthony E.
org:            ELMCO, Inc.
email;internet: aeg@hiwaay.net
title:          Senior Software Engineer
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ada help please
       [not found] <36ab9c3f.2963059@news.ptd.net>
  1999-01-25  0:00 ` ada help please Anthony E. Glover
@ 1999-01-26  0:00 ` Tom Moran
  1999-02-01  0:00   ` Robert I. Eachus
  1999-02-01  0:00 ` Nick Roberts
  2 siblings, 1 reply; 4+ messages in thread
From: Tom Moran @ 1999-01-26  0:00 UTC (permalink / raw)


>you cant add two characters and you cant typecast them to integers, so
>how
>do u get the result of the sums into Z?
  The old IBM 1620 did this with an addition table.  ie, make two,
two-dimensional arrays (one for "with carry", one without) indexed by
the characters '0' .. '9' to give the sum character.  Initialize these
constant arrays yourself from any 1st grade arithmetic text.  You'll
also need similar arrays of Boolean to tell if you should generate a
carry.
  Just one approach. ;)  




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ada help please
  1999-01-26  0:00 ` Tom Moran
@ 1999-02-01  0:00   ` Robert I. Eachus
  0 siblings, 0 replies; 4+ messages in thread
From: Robert I. Eachus @ 1999-02-01  0:00 UTC (permalink / raw)


In article <36ad2d46.24886495@news.pacbell.net> tmoran@bix.com (Tom Moran) writes:

 >   The old IBM 1620 did this with an addition table.  ie, make two,
 > two-dimensional arrays (one for "with carry", one without) indexed by
 > the characters '0' .. '9' to give the sum character.  Initialize these
 > constant arrays yourself from any 1st grade arithmetic text.  You'll
 > also need similar arrays of Boolean to tell if you should generate a
 > carry.

   Ah, someone else who remembers the CADET (Can't Add Doesn't Even Try).
Seriously, since the 1620 allowed overwriting of the addition and
multiplication tables, you could change the arithmetic base, but only
to values less than 10.  So a lot of work got done studying base 7
arithmetic.  (The largest prime base possible on the 1620.)  I
expected Ada's support for bases up to 16 to result in a flurry of
papers on base 13.

--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ada help please
       [not found] <36ab9c3f.2963059@news.ptd.net>
  1999-01-25  0:00 ` ada help please Anthony E. Glover
  1999-01-26  0:00 ` Tom Moran
@ 1999-02-01  0:00 ` Nick Roberts
  2 siblings, 0 replies; 4+ messages in thread
From: Nick Roberts @ 1999-02-01  0:00 UTC (permalink / raw)


At the risk of doing your homework for you, declare

   subtype Digit is Character range '0'..'9';

   DigVal: constant array (Digit) of Integer :=
      (0,1,2,3,4,5,6,7,8,9);

Now you can add up by having something like

   DigSum := DigVal(A(i)) + DigVal(B(i)) + Carry;

in your loop. Good luck!

-------------------------------------------
Nick Roberts
-------------------------------------------







^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-02-01  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <36ab9c3f.2963059@news.ptd.net>
1999-01-25  0:00 ` ada help please Anthony E. Glover
1999-01-26  0:00 ` Tom Moran
1999-02-01  0:00   ` Robert I. Eachus
1999-02-01  0:00 ` Nick Roberts

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