]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/fortran/doc/gfortran/intrinsic-procedures/modulo.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / fortran / doc / gfortran / intrinsic-procedures / modulo.rst
1 ..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6 .. index:: MODULO, modulo, division, modulo
7
8 .. _modulo:
9
10 MODULO --- Modulo function
11 **************************
12
13 .. function:: MODULO(A,P)
14
15 ``MODULO(A,P)`` computes the :samp:`{A}` modulo :samp:`{P}`.
16
17 :param A:
18 Shall be a scalar of type ``INTEGER`` or ``REAL``.
19
20 :param P:
21 Shall be a scalar of the same type and kind as :samp:`{A}`.
22 It shall not be zero. (As a GNU extension, arguments of different kinds are
23 permitted.)
24
25 :return:
26 The type and kind of the result are those of the arguments. (As a GNU
27 extension, kind is the largest kind of the actual arguments.)
28
29 Standard:
30 Fortran 95 and later
31
32 Class:
33 Elemental function
34
35 Syntax:
36 .. code-block:: fortran
37
38 RESULT = MODULO(A, P)
39
40 Example:
41 .. code-block:: fortran
42
43 program test_modulo
44 print *, modulo(17,3)
45 print *, modulo(17.5,5.5)
46
47 print *, modulo(-17,3)
48 print *, modulo(-17.5,5.5)
49
50 print *, modulo(17,-3)
51 print *, modulo(17.5,-5.5)
52 end program
53
54 See also:
55 :ref:`MOD`