(j3.2006) Question about DIM

Cohen Malcolm malcolm
Thu Jan 14 00:50:47 EST 2016

>Without the internal checks, there is little point to DIM.

DIM does not have any internal checks, and none are possible when the result 
is out of range.  You are arguing that the standard should mandate one 
particular wrong answer; this is *NOT* an improvement on the current 
situation, indeed it is a disimprovement since the error is detectable at 

> The result for DIM involves a decision:
>if (X-Y > 0) then
>  result = x-y
>  result = 0
>end if

No, that is not the case.  The wording of DIM is

    "The value of the result is the maximum of X ? Y and zero."

This is a mathematical definition, not a piece of Fortran code.  There is no 
ambiguity here - when X>=Y the result is specified to be X-Y, and if that is 
out of range that means the program is invalid.

(When the result is in range the result can be computed with no branching on 
many machines, but that's a horse of a different colour.)

Back on the erroneous Fortran code which does not appear in the standard 
>One could argue that if X-Y is out of bounds, it is unreasonable to claim 
>that X-Y > 0 evaluates to true.  Rather, in that case the result is 0, 
>which is certainly a representable value.

Since you are arguing Fortran code, if X-Y is out of bounds then it is 
invalid to compute it.  Rather, in that case the result is anything from 
program termination to playing Jingle Bells through the speakers.

>It is probably the case that no one has looked at DIM since we made X-Y>0 a 
>valid syntax for a logical expression.  Which is why I proposed alternate 
>wording that avoids using the expression.

But since the standard ***does not use that expression*** we have already 
successfully avoided it.

........................Malcolm Cohen, Nihon NAG, Tokyo. 

More information about the J3 mailing list