[comp.software-eng] Floating Point in COBOL

warren@jove.cs.pdx.edu (Warren Harrison) (05/05/89)

Perhaps this is stretching a point since after checking, I found out this
is an IBM extension to the ANSI-78 standard, but COMP-1 and COMP-2 are
single and double word floating point data types, aligned on fullword and
doubleword boundaries, respectively.  Computational is fixed point.   True,
COMP-3 (packed decimal) is limited to 36 characters, but I know of no other
language which provides this much accuracy (remember, this stuff is stored
in base 10, so round off errors are significantly reduced) in a data type.
36 decimal places is: 999999999999999999999999999999999999.

Please note that I didn't suggest COBOL was an all purpose programming
language, but that modular programs could be written at least as easy in
it as in most other langauges, and much easier than in many other languages.

The overhead of a COBOL subprogram call is probably less than the overhead
of a Pascal call since local variables do not have to be generated each time
(data items within the subprogram are static), thus you have less of a performance
ding against subprogram calls than in many other "modular" langauges.

I know of many non-commercial applications that have been written in COBOL.
For example I have been told that Micro Focus COBOL/2 is written in COBOL.
I myself have written a COBOL subset compiler in COBOL (and Pascal
compilers in Pascal - I failed to see much difference once you're familiar
with the language).  So far, no operating systems or flight control software
though :-)

Warren

Warren Harrison                CSNET: warren@pdx.edu
Department of Computer Science UUCP:  {ucbvax,decvax}!tektronix!psu-cs!warren
Portland State University      Internet: warren%pdx.edu@relay.cs.net
Portland, OR 97207-0751

len@synthesis.Synthesis.COM (Len Lattanzi) (05/06/89)

In article <1137@psueea.UUCP> warren@jove.cs.pdx.edu (Warren Harrison) writes:
:Perhaps this is stretching a point since after checking, I found out this
:is an IBM extension to the ANSI-78 standard, but COMP-1 and COMP-2 are
:single and double word floating point data types, aligned on fullword and
:doubleword boundaries, respectively.  Computational is fixed point.   True,
:COMP-3 (packed decimal) is limited to 36 characters, but I know of no other
:language which provides this much accuracy (remember, this stuff is stored
:in base 10, so round off errors are significantly reduced) in a data type.
:36 decimal places is: 999999999999999999999999999999999999.
:

As far as I know the COMP-1/COMP-2 are only supported by IBM and 
LPI-COBOL, so portable cobol programmers would probably avoid them.

As for extended precision data types, Common Lisp has unlimited size
bignums. I like the ability to work with >32 bit numbers but limiting me
to 64 bits is similar to telling me I can use recursion but only to 6
instantiations.

:Please note that I didn't suggest COBOL was an all purpose programming
:language, but that modular programs could be written at least as easy in
:it as in most other langauges, and much easier than in many other languages.
:
:The overhead of a COBOL subprogram call is probably less than the overhead
:of a Pascal call since local variables do not have to be generated each time
:(data items within the subprogram are static), 
:thus you have less of a performance
:ding against subprogram calls than in many other "modular" langauges.
:
Many FORTRAN implementations work this way (and many non-standard FORTRAN
programs depend on static locals) but often you find that using local stack
variables is faster because the variables have greater locality [parent &
childs locals are less likely to collide in data caches] and can
be referenced relative to the stack pointer rather than building a static
address.

:I know of many non-commercial applications that have been written in COBOL.
:For example I have been told that Micro Focus COBOL/2 is written in COBOL.
:I myself have written a COBOL subset compiler in COBOL (and Pascal
:compilers in Pascal - I failed to see much difference once you're familiar
:with the language).
Well don't try any recursive descent parsers :-)

:  So far, no operating systems or flight control software
:though :-)
:
:Warren
:
:Warren Harrison                CSNET: warren@pdx.edu
:Department of Computer Science UUCP:  {ucbvax,decvax}!tektronix!psu-cs!warren
:Portland State University      Internet: warren%pdx.edu@relay.cs.net
:Portland, OR 97207-0751


 Len Lattanzi (len@Synthesis.com) <{ames,pyramid,decwrl}!mips!synthesis!len>
 Synthesis Software Solutions, Inc. 		The RISC Software Company
I would have put a disclaimer here but I already posted the article.