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

Bill Long longb
Mon Oct 27 17:03:10 EDT 2008


I'd cite f08:[140:para 3]  "The execution of any numeric operation whose 
result is not defined by the arithmetic used by the processor is 
prohibited."

Cheers,
Bill


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)?
>
> 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 this 
> confirm that Fortran language will view this computation as invalid?
>
> Thanks,
>
>
> Jim Xia
>
> RL Fortran Compiler Test
> IBM Toronto Lab at 8200 Warden Ave, Markham, On, L6G 1C7
> Phone (905) 413-3444  Tie-line 313-3444
> email: jimxia at ca.ibm.com
> D2/YF7/8200 /MKM
> ------------------------------------------------------------------------
>
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3
>   

-- 
Bill Long                                   longb at cray.com
Fortran Technical Support    &              voice: 651-605-9024
Bioinformatics Software Development         fax:   651-605-9142
Cray Inc., 1340 Mendota Heights Rd., Mendota Heights, MN, 55120

            




More information about the J3 mailing list