|
|
|

The math_s service program contains the math library functions, plus a couple of extra functions. These are all wrapped in a service program so that your application only has to bind to this service program. You will not need to bind to the QC2LE directory in your application.
Math_P Prototypes
/IF Defined(Math_p)
/Eof
/EndIf
/Define Math_p
d Math_pi c 3.14159265358979323846
* ----------------------------------------------------------------------
* Calculates the arccosine of VariableX and returns the result in radians
*
d Math_ArcCosine pr 8f Extproc( 'acos' )
d VariableX 8f value
* ----------------------------------------------------------------------
* Calculates the arcsine of VariableX and returns the result in radians
*
d Math_ArcSine pr 8f Extproc( 'asin' )
d VariableX 8f value
* ----------------------------------------------------------------------
* Calculates the arc tangent of VariableX and returns the result in radian
*
d Math_ArcTangent...
d pr 8f Extproc( 'atan' )
d VariableX 8f value
* -----------------------------------------------------------------------
* Calculates the arctangent hyperbolic of VariableX and returns the
* result in radians
d Math_ArcTangentHyperbolic...
d pr 8f Extproc( 'atan2' )
d VariableX 8f value
d VariableY 8f value
* ----------------------------------------------------------------------
* Calculates the cosine of VariableX and returns the result in radians
*
d Math_Cosine pr 8f Extproc( 'cos' )
d VariableX 8f value
* -----------------------------------------------------------------------
* Calculates the cosine hyperbolic of VariableX and returns the
* result in radians
d Math_CosineHyperbolic...
d pr 8f Extproc( 'cosh' )
d VariableX 8f value
* -----------------------------------------------------------------------
* calculates the natural logarithm (base e) of VariableX
d Math_Log pr 8f Extproc( 'log' )
d VariableX 8f value
* -----------------------------------------------------------------------
* calculates the base 10 logarithm of VariableX
d Math_Log10 pr 8f Extproc( 'log10' )
d VariableX 8f value
* ----------------------------------------------------------------------
* Calculates the sine of VariableX and returns the result in radians
*
d Math_Sine pr 8f Extproc( 'sin' )
d VariableX 8f value
* ----------------------------------------------------------------------
* Calculates the sine hyperbolic of VariableX and returns the
* result in radians
* d Math_SineHyperbolic...
d Math_SineHyperbolic...
d pr 8f Extproc( 'sinh' )
d VariableX 8f value
* ----------------------------------------------------------------------
* Calculates the tangent of VariableX and returns the result in radians
*
d Math_Tangent pr 8f Extproc( 'tan' )
d VariableX 8f value
* ----------------------------------------------------------------------
* Calculates the tangent hyperbolic of VariableX and returns the
* result in radians
*
d Math_TangentHyperbolic...
d pr 8f Extproc( 'tanh' )
d VariableX 8f value
* ----------------------------------------------------------------------
* Calculates the natural logrithm of the absolute value of VariableX
d Math_Gamma pr 8f Extproc( 'gamma' )
d VariableX 8f value
* -----------------------------------------------------------------------
* The hypotenuse function calculates the length of the hypotenuse of a
* right-angled triangle based on the lengths of two sides side1 and side2
d Math_Hypotenuse...
d pr 8f Extproc( 'hypot' )
d Side1 8f value
d Side2 8f value
* -----------------------------------------------------------------------
* Converts radians in the AngleRadians field to degrees
d Math_RadiansToDegrees...
d pr 8f
d AngleRadians 8f const
* -----------------------------------------------------------------------
* Converts degrees in the AngleDegrees field to radians
d Math_DegreesToRadians...
d pr 8f
d AngleDegrees 8f const
Math_S Service Program
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* M A T H _ S S e r v i c e P r o g r a m
*
* @copyrite 1997, 2009 Michael Catalani
* ProvatoSys www.ProvatoSys.com
* mcatalani@aol.com
* 901.581.8791
*
*
* FUNCTION DESCRIPTION
* RadiansToDegrees Returns the Angle Degrees of a Radian
* DegreesToRadians Returns the Radian value of an angle
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
h nomain BndDir( 'QC2LE' )
/copy *libl/qrpglesrc,math_p
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* M a t h _ R a d i a n s T o D e g r e e s
*
* Convert Radians to Degrees
*
* Input Field - Radians ( floating point )
* Returns - Degrees ( floating point )
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
p Math_RadiansToDegrees...
p b export
d Math_RadiansToDegrees...
d pi 8f
d AngleRadians 8f const
d Degrees s 8f
/free
Degrees = 180 * AngleRadians / Math_PI;
Return Degrees;
/end-free
p e
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* M a t h _ D e g r e e s T o R a d i a n s
*
* Convert Degrees to Radians
*
* Input Field - Degrees ( floating point )
* Returns - Radians ( floating point )
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
p Math_DegreesToRadians...
p b export
d Math_DegreesToRadians...
d pi 8f
d AngleDegrees 8f const
d Radians s 8f
/free
Radians = Math_PI * AngleDegrees / 180;
Return Radians;
/end-free
p e
Math_S Binder Source
STRPGMEXP PGMLVL(*CURRENT)
EXPORT SYMBOL(Math_RadiansToDegrees)
EXPORT SYMBOL(Math_DegreesToRadians)
ENDPGMEXP
Creating The Service Program
CRTRPGMOD MODULE(CF/MATH_S) SRCFILE(CF/QRPGLESRC)
CRTSRVPGM SRVPGM(CF/MATH_S)
** replace the library "CF" with the library you are using.
Perform an ADDBNDDIRE to place the service program into a binding directory.