(j3.2006) is MOD (INT_MIN, -1) legal?

Dan Nagle dannagle
Mon Oct 27 16:50:33 EDT 2008


Hi,

On Oct 27, 2008, at 4:43 PM, Jim Xia wrote:

>
> This discussion originally came from C community on INT_MIN % (-1).   
> Say you have a minimum integer value, INT_MIN (e.g. -HUGE(1) - 1),  
> then is it a legal Fortran code to compute MOD(INT_MIN, -1)?

Is INT_MIN the same as -huge( 0) ?

Is mod() the same as % ?
>
>
> Based on the text in 13.7.80 of F03, MOD(A,P) is interpreted as A -  
> INT ( A / P) * P.  This expression applied on MOD(INT_MIN, -1) will  
> result in a computation of INT_MIN / (-1), which overflows.

Does is overflow as per the standard,
or just in some implementations?

>  Does this confirm that Fortran language will view this computation  
> as invalid?


If I could answer all the above from the integer model,
I'd most likely answer.

-- 
Cheers!

Dan Nagle







More information about the J3 mailing list