HP3000-L Archives

January 1999, Week 1

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Steve Fatula <[log in to unmask]>
Reply To:
Steve Fatula <[log in to unmask]>
Date:
Wed, 6 Jan 1999 02:09:07 GMT
Content-Type:
text/plain
Parts/Attachments:
text/plain (39 lines)
To add to another responder,

it IS just a warning. So, you may choose to ignore it. The problem of course
is the real number format. Doing addition and subtraction which in Cobol
might come out to zero will not necessarily come out to zero using real
numbers. So, this is why the warning is there.

In the code we wrote in the past, we compared to near zero, not exactly
zero. Seems silly to a Cobol programmer, but it is because of the real
number format.

Of course, another alternative is

IF (ABS(ZAMOUNT) .LT. .0001)

Michael Anderson wrote:

> I have been writing COBOL code for the last 9-10 years, and the last six
> months Fortran 66. Now converting the 66 code to 77.  It seems
> ridiculous that I am not able to use a simple "IF" statement to see if a
> double precision variable is equal to zero in FORTRAN 77.
> IF (ZAMOUNT .EQ. 0.00D0) ...
>
> A compile warning (781) states: Test may fail due to floating point
> imprecision. This occurs when ".EQ." or ".NE." is used in the
> comparison. So, the only work-around in Fortran77 is to do something
> like:
>
> IF (ZAMOUNT .LT. 0.0001 .AND. ZAMOUNT .GT. -0.0001) .....
>
> Can anyone tell me how I can keep from modifying every "IF" statement
> that has an ".EQ." or ".NE"?
>
> TIA,
>
> Michael Anderson
> TIW Corporation
> Houston, Tx (713) 729-2110 ext:100

ATOM RSS1 RSS2