INT Function Producing Incorrect Answer

Product Version(s): 3.20
Operating System:   MS-DOS
Flags: ENDUSER |
Last Modified: 20-OCT-1988    ArticleIdent: Q10647

Problem:

The function INT produces an incorrect answer if given a mixed-mode
expression. The following code sample returns the value 94 (it should
return the value 95):

       s = .95
       n = 100
       i = int (n*s)
       write (*,*) s,n,i
       x = n*s
       j = int(x)
       write (*,*) x,j
       end

Response:

This is not a problem with the compiler. The different values in the
above example are obtained because, in the first case, truncation
occurs after the value has been rounded to an 80-bit representation of
the expression 100 * .95. In the second case, truncation occurs after
the value has been rounded to a 32-bit representation.