mirror of
https://github.com/nasa/trick.git
synced 2025-02-04 02:01:23 +00:00
14a75508a3
Changed all header file once include variables to follow the same naming convention and not start with any underscores. Also deleted old incorrect copyright notices. Also removed $Id: tags from all files. Fixes #14. Fixes #22.
27 lines
746 B
C
27 lines
746 B
C
/*
|
|
PURPOSE: (Round off a double precision value to the resolution specified.)
|
|
REFERENCE: ((None))
|
|
ASSUMPTIONS AND LIMITATIONS: ((none))
|
|
CLASS: (N/A)
|
|
LIBRARY DEPENDENCY: ((roundoff.o))
|
|
PROGRAMMERS: (((Robert W. Bailey) (LinCom Corp) (Feb 1991) (v1.0) (Initial Release.)))
|
|
*/
|
|
|
|
#include "../include/trick_math.h"
|
|
|
|
double roundoff( /* Return: Value after roundoff */
|
|
double res, /* In: Resolution for roundoff function */
|
|
double val)
|
|
{ /* In: Value to be truncated */
|
|
|
|
double remain;
|
|
|
|
remain = fmod(val, res);
|
|
|
|
if ((remain / res) <= 0.5)
|
|
return (val - remain);
|
|
else
|
|
return (val + ((1.0 * res) - remain));
|
|
|
|
}
|