(j3.2006) is MOD (INT_MIN, -1) legal?
Mon Oct 27 21:40:30 EDT 2008
If 188.8.131.52.4p1-2 applies to numeric intrinsic functions as well as to
numeric intrinsic operations, the calculation of MPD(INT_MIN,-1) doesn't
have to overflow.
If those paragraphs don't apply to numeric intrinsic functions, perhaps
On Mon, 2008-10-27 at 14:12 -0800, Michael Ingrassia wrote:
> Interesting question!
> >MOD(A,P) is interpreted as A - INT ( A / P) * P
> That's not what I read in 13.7.80. There's no explicit or implicit
> claim that the MOD intrinsic is "interpreted". Rather, it has a value
> which is mathematically given as A-INT (A/P) * P. Sounds fussy, but I
> think it matters here.
> >This expression applied on MOD(INT_MIN, -1) ... overflows.
> The reason it matters is that mathematical expressions might not overflow nearly
> so often as computational expressions.
> If "v" is a valuation function which takes Fortran expressions and
> produces mathematical values (say, leftover from some denotational semantics
> paper), then it makes sense that
> v(A - INT(A/P)*P) = v(A) - v(INT(A/P)*P)
> = v(A) - v(INT(A/P))*v(P)
> = v(A) - v(A/P)*v(P) ! 13.7.53 case (i)
> and for A equal to INT_MIN and P equal to (-1), the Fortran expression
> A/P does overflow on my processor and it might be that mathematically
> v(overflow-expression) is some sort of Infinite value. At this point
> we need to know the range of the valuation function v. For integers,
> we haven't blessed any particular model with an Infinity, so I think we're
> stuck concluding that the standard has cunningly failed to specify a
> value for MOD in this case.
> Some ways out:
> 1) we only claim to specify models for inputs that can be described in
> terms of the Integer model. On the edges, you're on your own.
> 2) we really didn't mean to make the value depend on whether A/P overflowed.
> we should come up with a better definition.
> 3) we really did mean that MOD can overflow if A/P overflows. We could add
> a NOTE that says so.
> --Michael I.
> J3 mailing list
> J3 at j3-fortran.org
More information about the J3