1 /*-------------- Telecommunications & Signal Processing Lab ---------------
2                              McGill University
3 
4 Routine:
5   double MSdNint (double x)
6 
7 Purpose:
8   Nearest integer function
9 
10 Description:
11   This routine returns the integer-valued double nearest x.  Specifically, the
12   returned value is floor(x+0.5) for positive x and ceil(x-0.5) for negative
13   x.
14 
15 Parameters:
16   <-  double MSdNint
17       Returned integer value
18    -> double x
19       Input value
20 
21 Author / revision:
22   P. Kabal  Copyright (C) 2003
23   $Revision: 1.7 $  $Date: 2003/05/09 02:29:38 $
24 
25 -------------------------------------------------------------------------*/
26 
27 #include <math.h>	/* floor and ceil */
28 
29 #include <libtsp.h>
30 
31 
32 double
MSdNint(double x)33 MSdNint (double x)
34 
35 {
36   double pint;
37 
38   if (x >= 0.0)
39     pint = floor (x + 0.5);
40   else
41     pint = ceil (x - 0.5);
42 
43   return pint;
44 }
45