https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61668
--- Comment #8 from Peter Ketel <ketelbinkje at gmail dot com> ---
So what is the use of a math library that is only capable of binary
computations?
In the real world we use the decimal system for all computations.
Do we need binary computations? In most cases NO.
What is the use of a real or double if it's only capable to approximate
a decimal fraction?
This piece of code will calculate the value for s correctly on a IBM
mainframe. Please note that this code was written 1966!
C AREA OF A TRIANGLE - HERON'S FORMULA
C INPUT - CARD READER UNIT 5, INTEGER INPUT
C OUTPUT - LINE PRINTER UNIT 6, REAL OUTPUT
C INPUT ERROR DISPAY ERROR OUTPUT CODE 1 IN JOB
CONTROL LISTING
INTEGER A,B,C
READ(5,501) A,B,C
501 FORMAT(3I5)
IF(A.EQ.0 .OR. B.EQ.0 .OR. C.EQ.0) STOP 1
S = (A + B + C) / 2.0
AREA = SQRT( S * (S - A) * (S - B) * (S -
C))
WRITE(6,601) A,B,C,AREA
601 FORMAT(4H A= ,I5,5H B= ,I5,5H C= ,I5,8H
AREA= ,F10.2,12HSQUARE UNITS)
STOP
END
This is the modern Fortan test program:
program main
implicit none
integer re_i
real :: Test =0.59
Test = (0.45 + 0.45 + 0.28) / 2
re_i = system("pause")
end
It wil fail to compute the correct value because it too uses binary
computation.
So why do we have real and double data types for computational purposes
that will never return a correct result?
Thank God we didn't use the crappy compilers anno 2014 when we flew to
the moon.
On 02-07-14 12:03, [email protected] wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61668
>
> --- Comment #7 from Andreas Schwab <[email protected]> ---
> Don't try to emulate decimal arithmetics with binary arithmetics.
>