rmaini |
Table of contents
ProcedureRMAINI ( Remainder --- integer ) SUBROUTINE RMAINI ( NUM, DENOM, Q, REM ) AbstractCompute the integer quotient and non-negative remainder of NUM and DENOM. Required_ReadingNone. KeywordsMATH UTILITY DeclarationsIMPLICIT NONE INTEGER NUM INTEGER DENOM INTEGER Q INTEGER REM Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- NUM I Numerator used to compute quotient and remainder. DENOM I Denominator used to compute quotient and remainder. Q O Integer portion of the quotient NUM/DENOM. REM O Remainder of the quotient NUM/DENOM. Detailed_InputNUM is the numerator of a quotient DENOM is the denominator of a quotient Detailed_OutputQ is the largest integer less than or equal to the quotient NUM/DENOM REM is the remainder of the integer division NUM/DENOM ParametersNone. Exceptions1) If DENOM is zero, the error SPICE(DIVIDEBYZERO) is signaled. FilesNone. ParticularsGiven the integer inputs NUM and DENOM, this routine finds integers Q and REM that satisfy the following conditions: 1) NUM = DENOM * Q + REM 2) REM is a non negative integer less than the absolute value of DENOM. This routine serves as a macro. In this way the code to perform this task can be written and maintained in a single location. ExamplesOne frequently needs to compute the ``360 modulus'' of a number. For positive numbers the FORTRAN intrinsic mod function works well. However, for negative numbers the intrinsic will return a negative modulus. This routine can be used to compute the positive 360 pi modulus (MOD360) for any integer I by the call: CALL RMAINI ( I, 360, Q, MOD360 ) RestrictionsNone. Literature_ReferencesNone. Author_and_InstitutionJ. Diaz del Rio (ODC Space) W.L. Taber (JPL) VersionSPICELIB Version 1.1.0, 12-AUG-2021 (JDR) Added IMPLICIT NONE statement. Edited the header to comply with NAIF standard. SPICELIB Version 1.0.0, 01-DEC-1995 (WLT) |
Fri Dec 31 18:36:43 2021