OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Arithmetic.h
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // "Copyright Centre National d'Etudes Spatiales"
4 //
5 // License: LGPL
6 //
7 // See LICENSE.txt file in the top level directory for more details.
8 //
9 //----------------------------------------------------------------------------
10 // $Id$
11 
12 #ifndef Arithmetic_h
13 #define Arithmetic_h
14 
15 #include <cmath>
16 #include <cstdlib>
17 
18 namespace ossimplugins
19 {
20 
21 
22 /*-------------------------------------------------------------------------*/
23 /* "closest integer" function, returns long */
24 /*-------------------------------------------------------------------------*/
25 
26  long inint (double x)
27  {
28  return (x >= 0.0) ? (long)(x + 0.5) : (long)(x-0.5) ;
29  }
30 
31 /*-------------------------------------------------------------------------*/
32 /* "closest integer" function, returns double */
33 /*-------------------------------------------------------------------------*/
34 
35  double fnint (double x)
36  {
37  return (x >= 0.0) ? (double)((long)(x + 0.5)) : (double)((long)(x - 0.5));
38  }
39 
40 
41 } // End: namespace ossimplugins
42 
43 #endif
ossim_uint32 x
double fnint(double x)
Definition: Arithmetic.h:35
long inint(double x)
Definition: Arithmetic.h:26