Operating System - OpenVMS
1828492 Members
2647 Online
109978 Solutions
New Discussion

using fortran and profor with upgraded VMS and Oracle

 
robert70
Valued Contributor

Re: using fortran and profor with upgraded VMS and Oracle

ignore that last question mike got that now with

real*16 max_real_16
parameter (max_real_16 = huge(0.0_16))
Dennis Handly
Acclaimed Contributor

Re: using fortran and profor with upgraded VMS and Oracle

>John: No matter how much floating point precision you have, you WILL get calculation errors

Not if you are using decimal floating point. :-)
John Gillings
Honored Contributor

Re: using fortran and profor with upgraded VMS and Oracle

re: Dennis,

>decimal floating point

True, but I'm specificically talking about BINARY FPFPR, which is all you get in Fortran and C.

In languages that support a Binary Coded Decimal (BCD) data types, like COBOL and BASIC, you can safely use them for monetary calculations, but in (for example) Fortran, C and Pascal where floating point is finite precision binary, it's very important that programmers understand the limitations of FPFPR arithmetic. Just one example, I'd contend that when using these data types, any code comparing two FPFPR variables for equality (".EQ." or "==") is almost certainly incorrect.

I'm concerned that the reason Robert is using (very) high precision data types (REAL*16) in this example is an attempt to "fix" the kind of errors which are inherent in the data type. It's fine for calculating load values on bridges, or astronomical distances, but NOT for calculating cap values for stocks or bank balances!
A crucible of informative mistakes
Dennis Handly
Acclaimed Contributor

Re: using fortran and profor with upgraded VMS and Oracle

>John: which is all you get in Fortran and C.
>but in (for example) Fortran, C and Pascal where floating point is finite precision binary

The next C Standard supports Decimal Floating Point and this is implemented on HP-UX 11.31.

>it's very important that programmers understand the limitations of FPFPR arithmetic.

Exactly, I learned that many decades ago.

>but NOT for calculating cap values for stocks or bank balances!

That's why DecFP was added to C.