[net.lang.ada] Integer division: a winner declared

weemba@brahms.BERKELEY.EDU (Matthew P. Wiener) (02/19/86)

In article <1970@peora.UUCP> jer@peora.UUCP (J. Eric Roskos) writes:
>The problem is, as far as the implementation of machines is concerned, Ada
>is likely to be the driving force for the forseeable future -- any company
>doing an implementation is faced with either complying with Ada, or
>suffering a performance penalty making the Ada compiler adapt the results
>of the division (in software) to suit the Ada definition.  Due to the
>DoD's requirement for Ada, it seems likely that most manufacturers would
>choose the Ada definition for the divide operations in their instruction
>sets.

You may be interested that many of the largest defense companies/contractors
consider Ada to be a complete joke and have no intention of making it available
unless their programmers start screaming and begging for it.  This includes
Los Alamos National Labs, Lawrence Livermore Labs, the National Security Agency,
NASA and Lockheed.  Considering that all the biggies run UNIX on Cray-2s and
are--if they are intelligent--moving towards workstations that will talk with
the Cray-2s quite easily (read UNIX workstations), it looks like that a large
portion of DoD programming will move towards C, not Ada.

Incidentally, LLL and NSA both have their own private languages.

>[Note that the Ada standard was open for public comment through many
>revisions, so if there was a strong opinion about division, it should have
>been (and probably was) voiced then.]

Yes and no.  Several companies were asked to make suggestions and they
laughed at the Ada idea even then.  I for one do not care what the Ada
standard is, and couldn't imagine why I would have wanted to contribute
any strong feelings about language design to a language I couldn't care
about.  Besides, I wouldn't be surprised if they chose the boneheaded
way of doing integer division for idiotic reasons anyway.

>Thus it looks like the "intuitive" Ada definition wins.

Hardy har har.

[And to net.lang.ada readers: sorry for picking on Ada, but I realize many
of you have no choice in the matter anyway.]

ucbvax!brahms!weemba	Matthew P Wiener/UCB Math Dept/Berkeley CA 94720

ladkin@kestrel.ARPA (Peter Ladkin) (02/21/86)

In article <11923@ucbvax.BERKELEY.EDU>, weemba@brahms.BERKELEY.EDU 
(Matthew P. Wiener) writes:
> You may be interested that many of the largest defense companies/contractors
> consider Ada to be a complete joke and have no intention of making it 
> available
> unless their programmers start screaming and begging for it.  This includes
> Los Alamos National Labs, Lawrence Livermore Labs, 
> the National Security Agency,
> NASA and Lockheed.

Considering ADA to be flawed - not in one of your cases.
Having no intention of making it available, again false in two of
your quoted list.
From first hand knowledge.

There is enormous pressure to write in ADA for DOD work.
DOE? No idea.

Peter Ladkin

ladkin@kestrel.ARPA (Peter Ladkin) (02/21/86)

In article <5030@kestrel.ARPA>, ladkin@kestrel.ARPA (Peter Ladkin) writes:
> Considering ADA to be flawed - not in one of your cases.

I meant - at least one of the organisations quoted doesn't 
consider ADA to be flawed.

> Having no intention of making it available, again false in two of
> your quoted list.
> From first hand knowledge.

To be read similarly. Sorry for the confusion.

Peter Ladkin

gsmith@brahms.BERKELEY.EDU (Gene Ward Smith) (02/21/86)

In article <127@diablo.ARPA> avg@diablo.UUCP (Allen VanGelder) writes:

>Ada clearly has it right.  Knuth agrees, but spells "rem" differently.
>Ada examples:
>	   5/ 3   =  1		 5 rem  3 =  2		 5 mod  3 =  2
>	(-5)/ 3   = -1		-5 rem  3 = -2		-5 mod  3 =  1
>	   5/(-3) = -1		 5 rem -3 =  2		 5 mod -3 = -2
>	(-5)/(-3) =  1		-5 rem -3 = -2		-5 mod -3 = -1
>

   It looks like I need to unsay most of the bad things I said about Ada.
Sorry about that, Adaphiles, but at first I thought J. Eric Roskos was
saying Ada had two mod-type functions, but later decided he was saying it
had only one (since he said Knuth's was different). I hope foot-in-mouth
disease isn't catching.

>For b > 0, Z_b = {0,1,2,...,b-1} by standard definition.  For b < 0
>I am unaware of any standard definition, but we might as well define
>Z_b = {0,-1,-2,...,b+1}.  Note that b+1 is the multiplicative identity.

   There is a standard remainder defintion for negative b, but it really
doesn't matter; the Knuth/Ada definition is just fine.

>I can't imagine implementing -5/3 = -2.  If you really need this, I

   Just today I needed this. It took an extra (C language) function 
definition. I have *never in my life*, to the best of my recollection,
wanted or needed -5/2 = -1. It's not as important as mod by any means,
so I will just leave you with this thought: it's still wrong, but the 
situation is improving. Maybe the next "language to end all languages"
after Ada will finally get it right.

ucbvax!brahms!gsmith    Gene Ward Smith/UCB Math Dept/Berkeley CA 94720
ucbvax!weyl!gsmith      "Dumb problem. DUMB!!!"