diff options
author | jb <jb@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-05-05 07:59:22 +0000 |
---|---|---|
committer | jb <jb@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-05-05 07:59:22 +0000 |
commit | fa0323b8cddaae96ccf2e8acc414baa926d4fa1f (patch) | |
tree | 8d0572d604c2f2a46fc172d68dceeb1635b87c47 /gcc/fortran/intrinsic.texi | |
parent | a291e3b6538a0697986d1a7d22aa220829998bab (diff) | |
download | gcc-fa0323b8cddaae96ccf2e8acc414baa926d4fa1f.tar.gz |
PR 49010,24518 MOD/MODULO fixes.
gcc/fortran:
2012-05-05 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/49010
PR fortran/24518
* intrinsic.texi (MOD, MODULO): Mention sign and magnitude of result.
* simplify.c (gfc_simplify_mod): Use mpfr_fmod.
(gfc_simplify_modulo): Likewise, use copysign to fix the result if
zero.
* trans-intrinsic.c (gfc_conv_intrinsic_mod): Remove fallback as
builtin_fmod is always available. For modulo, call copysign to fix
the result when signed zeros are enabled.
testsuite:
2012-05-05 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/49010
PR fortran/24518
* gfortran.dg/mod_sign0_1.f90: New test.
* gfortran.dg/mod_large_1.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187191 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/intrinsic.texi')
-rw-r--r-- | gcc/fortran/intrinsic.texi | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi index 294818e43d0..9bc36d7d415 100644 --- a/gcc/fortran/intrinsic.texi +++ b/gcc/fortran/intrinsic.texi @@ -8991,8 +8991,7 @@ cases, the result is of the same type and kind as @var{ARRAY}. @table @asis @item @emph{Description}: -@code{MOD(A,P)} computes the remainder of the division of A by P@. It is -calculated as @code{A - (INT(A/P) * P)}. +@code{MOD(A,P)} computes the remainder of the division of A by P@. @item @emph{Standard}: Fortran 77 and later @@ -9005,14 +9004,16 @@ Elemental function @item @emph{Arguments}: @multitable @columnfractions .15 .70 -@item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL} -@item @var{P} @tab Shall be a scalar of the same type as @var{A} and not -equal to zero +@item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}. +@item @var{P} @tab Shall be a scalar of the same type and kind as @var{A} +and not equal to zero. @end multitable @item @emph{Return value}: -The kind of the return value is the result of cross-promoting -the kinds of the arguments. +The return value is the result of @code{A - (INT(A/P) * P)}. The type +and kind of the return value is the same as that of the arguments. The +returned value has the same sign as A and a magnitude less than the +magnitude of P. @item @emph{Example}: @smallexample @@ -9041,6 +9042,10 @@ end program test_mod @item @code{AMOD(A,P)} @tab @code{REAL(4) A,P} @tab @code{REAL(4)} @tab Fortran 95 and later @item @code{DMOD(A,P)} @tab @code{REAL(8) A,P} @tab @code{REAL(8)} @tab Fortran 95 and later @end multitable + +@item @emph{See also}: +@ref{MODULO} + @end table @@ -9066,8 +9071,9 @@ Elemental function @item @emph{Arguments}: @multitable @columnfractions .15 .70 -@item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL} -@item @var{P} @tab Shall be a scalar of the same type and kind as @var{A} +@item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}. +@item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}. +It shall not be zero. @end multitable @item @emph{Return value}: @@ -9080,7 +9086,8 @@ The type and kind of the result are those of the arguments. @item If @var{A} and @var{P} are of type @code{REAL}: @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}. @end table -In all cases, if @var{P} is zero the result is processor-dependent. +The returned value has the same sign as P and a magnitude less than +the magnitude of P. @item @emph{Example}: @smallexample @@ -9096,6 +9103,9 @@ program test_modulo end program @end smallexample +@item @emph{See also}: +@ref{MOD} + @end table |