Re: If you were inventing CoBOL...

From: Chuck Stevens (charles.stevens_at_unisys.com)
Date: 09/16/04


Date: Thu, 16 Sep 2004 09:50:08 -0700


"Robert Wagner" <robert@wagner.net.yourmammaharvests> wrote in message
news:d8vik09juqiqgm1hoci50idp18gkegopp4@4ax.com...

> It seems clear that GIVING was required in the '68 standard. The rule
> prior to '68 is less clear.

ANSI X3.23-1968 is also regularly referred to as "First Standard COBOL".
That should tell you something.

COBOL rules before 1968 were pretty much a gentlemen's agreement, with input
from users, among compiler vendors. There was no *rule* before '68, and
the *guidelines* that existed back then appear to me not to have included
DIVIDE ... BY without GIVING.

> We've seen other cases of changes missing from the substantive change
> list.

True enough, but the fact that it's not there in two conformant '68
implementation and one COBOL-60 implementation does not lead me to believe
it was a substantive change in '74, noted or otherwise.

> Agreed. I made a mental note to avoid DIVIDE BY and have not used it
> since.

That's a far cry from "GIVING wasn't required in the good old days."

> While we're on the topic .. it would nice of we could write DIVIDE A
> INTO B GIVING REMAINDER C. I often want just the remainder, don't care
> about the quotient. For example: divide 7 into
> integer-of-date(current-date) giving remainder day-of-week-today.

I think I'd have to argue that this should be reflected as
    divide 7 into integer-of-date (current-date (1:8)) giving remainder
day-of-week-today.
I'm personally uncomfortable with the idea of passing those other 13
characters to the integer-of-date function, and wouldn't be surprised at a
fatal EC-ARGUMENT-FUNCTION exception were I to try it.

That being said, what the remainder looks like is dependent on the
relationship among the descriptions of the divisor, the dividend and the
quotient. In the general case your suggestion wouldn't produce meaningful
results.

There are other ways to skin a cat, and the ISO date proposal for the 2008
standard provides for
    MOVE CURRENT-FORMATTED-DATE ("YYYYWwwD") (8:1) TO day-of-week-today.
which I think is a whole lot clearer way to accomplish what you wish here.

You can even write your own function to do this today, if it's important
enough to you.

Can you not accomplish DIVIDE REMAINDER without INTO or GIVING today with
the arithmetics and the various intrinsic functions?

    -Chuck Stevens



Relevant Pages

  • Re: Assemblers are for hiding your work , not for faster code .
    ... I'm concatenating the 32-bit remainder ... Divide 0:H by 10; quotient is MS output, ... and drop one or more numerator digits to ...
    (comp.arch.embedded)
  • Re: OT: A puzzle -
    ... On Thu, 08 May 2008 02:59:13 GMT, Wes Groleau ... Divide by four What is the remainder? ... The instructions are not clear. ...
    (alt.support.diabetes)
  • Re: OT: A puzzle -
    ... Divide by four What is the remainder? ... was either two or seven _before_ I finished saying, ... The instructions are not clear. ...
    (alt.support.diabetes)
  • Re: The state-of-the-art in mathematics
    ... A and B are both nonempty. ... change state to the remainder and ... divide 10/3, change state to the remainder and ...
    (sci.math)
  • Re: Fast Binary to BCD method on ARM9 with huge numbers?
    ... >> largest power of ten you can comfortably divide by. ... quotient. ... As to the remainder, the above does not generate it, and you have to ... multiplications and some simple logic. ...
    (comp.arch.embedded)