Clicky

Fortran Wiki
modulo (changes)

Skip the Navigation Links | Home Page | All Pages | Recently Revised | Authors | Feeds | Export |

Showing changes from revision #5 to #6: (追記) Added (追記ここまで) | (削除) Removed (削除ここまで) | (削除) Chan (削除ここまで)(追記) ged (追記ここまで)

Description

modulo(a,p) computes the a modulo p.

Standard

Fortran 95 and later

Class

Elemental function

Syntax

(削除)

result = modulo(a, p)

(削除ここまで)
(追記)
result = modulo(a, p)
(追記ここまで)

Arguments

  • a - Shall be a scalar of type integer or real(追記) . (追記ここまで)
  • p - Shall be a scalar of the same type and kind as a(追記) . It shall not be zero. (追記ここまで)

Return value

The type and kind of the result are those of the arguments.

  • If a and p are of type integer: modulo(a,p) has the value of a - floor (real(a) / real(p)) * p.
  • If a and p are of type real: modulo(a,p) has the value of a - floor (a / p) * p.

(削除) In (削除ここまで)(追記) The (追記ここまで)(削除) all (削除ここまで)(追記) returned (追記ここまで)(削除) cases, (削除ここまで)(追記) value (追記ここまで)(削除) if (削除ここまで)(追記) has (追記ここまで)(追記) the (追記ここまで)(追記) same (追記ここまで)(追記) sign (追記ここまで)(追記) as (追記ここまで)p (削除) is (削除ここまで)(追記) and (追記ここまで)(削除) zero (削除ここまで)(追記) a (追記ここまで)(追記) magnitude (追記ここまで)(追記) less (追記ここまで)(追記) than (追記ここまで) the(削除) result (削除ここまで)(追記) magnitude (追記ここまで)(削除) is (削除ここまで)(追記) of (追記ここまで)(削除) processor-dependent. (削除ここまで)(追記) p (追記ここまで)(追記) . (追記ここまで)

Example

program test_modulo
 print *, modulo(17,3) ! yields 2
 print *, modulo(17.5,5.5)(削除) 
 (削除ここまで)(削除) 
 (削除ここまで)(追記) ! yields 1.0 (追記ここまで)(追記) 
 (追記ここまで)print *, modulo(-17,3)(削除) 
 (削除ここまで)(追記) ! yields 1 (追記ここまで)(追記) 
 (追記ここまで)print *, modulo(-17.5,5.5)(削除) 
 (削除ここまで)(削除) 
 (削除ここまで)(追記) ! yields 4.5 (追記ここまで)(追記) 
 (追記ここまで)print *, modulo(17,-3)(削除) 
 (削除ここまで)(追記) ! yields -1 (追記ここまで)(追記) 
 (追記ここまで)print *, modulo(17.5,-5.5)(追記)  (追記ここまで)(追記) ! yields -4.5 (追記ここまで)
end program
(追記) (追記ここまで)(追記)

See also

(追記ここまで)
(追記) (追記ここまで)(追記)

mod

(追記ここまで)

category: intrinsics

Revised on April 4, 2016 14:35:48 by Jason Blevins (128.146.137.52) (1272 characters / 0.0 pages)
Edit | Back in time (5 revisions) | Hide changes | History | Views: Print | TeX | Source | Linked from: Intrinsic procedures, mod

AltStyle によって変換されたページ (->オリジナル) /