1 /* exact.f -- translated by f2c (version 19980913).
2    You must link the resulting object file with the libraries:
3 	-lf2c -lm   (in that order)
4 */
5 
6 #include "f2c.h"
7 
8 /* $Procedure                     EXACT ( Round to exact value ) */
exact_(doublereal * number,doublereal * value,doublereal * tol)9 doublereal exact_(doublereal *number, doublereal *value, doublereal *tol)
10 {
11     /* System generated locals */
12     doublereal ret_val, d__1;
13 
14 /* $ Abstract */
15 
16 /*     Round an input double precision number to a specified exact value */
17 /*     if the number and the value are equal to within some tolerance. */
18 
19 /* $ Disclaimer */
20 
21 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
22 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
23 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
24 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
25 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
26 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
27 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
28 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
29 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
30 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
31 
32 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
33 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
34 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
35 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
36 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
37 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
38 
39 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
40 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
41 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
42 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
43 
44 /* $ Required_Reading */
45 
46 /*     None. */
47 
48 /* $ Keywords */
49 
50 /*     COMPARE */
51 /*     NUMBERS */
52 
53 /* $ Declarations */
54 /* $ Brief_I/O */
55 
56 /*     VARIABLE  I/O  DESCRIPTION */
57 /*     --------  ---  -------------------------------------------------- */
58 /*     NUMBER     I   Double precision number. */
59 /*     VALUE      I   Target value. */
60 /*     TOL        I   Tolerance. */
61 
62 /*     The function returns VALUE whenever |NUMBER - VALUE| < TOL. */
63 /*                                                          - */
64 
65 /* $ Detailed_Input */
66 
67 /*     NUMBER      is an arbitrary double precision number. */
68 
69 /*     VALUE       is a target value. */
70 
71 /*     TOL         is a tolerance. NUMBER and VALUE are considered to */
72 /*                 be equal if they differ by no more than this amount. */
73 /*                 If TOL is negative, they are never considered equal. */
74 
75 /* $ Detailed_Output */
76 
77 /*     The function returns VALUE whenever |NUMBER - VALUE| < TOL, and */
78 /*     otherwise returns NUMBER.                            - */
79 
80 /* $ Parameters */
81 
82 /*     None. */
83 
84 /* $ Exceptions */
85 
86 /*      Error free. */
87 
88 /* $ Files */
89 
90 /*     None. */
91 
92 /* $ Particulars */
93 
94 /*     None. */
95 
96 /* $ Examples */
97 
98 /*     C */
99 /*     C     If the eccentricity is near one, make this a parabola. */
100 /*     C */
101 /*           ECC = EXACT ( ECC, 1.D0, 10.D-12 ) */
102 
103 /* $ Restrictions */
104 
105 /*     None. */
106 
107 /* $ Literature_References */
108 
109 /*     None. */
110 
111 /* $ Author_and_Institution */
112 
113 /*     I.M. Underwood  (JPL) */
114 
115 /* $ Version */
116 
117 /* -     SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
118 
119 /*         Comment section for permuted index source lines was added */
120 /*         following the header. */
121 
122 /* -     SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
123 
124 /* -& */
125 /* $ Index_Entries */
126 
127 /*     round to exact value */
128 
129 /* -& */
130 
131 /*     Just shorthand, really. */
132 
133     if ((d__1 = *number - *value, abs(d__1)) <= *tol) {
134 	ret_val = *value;
135     } else {
136 	ret_val = *number;
137     }
138     return ret_val;
139 } /* exact_ */
140 
141