/*-------------- Telecommunications & Signal Processing Lab --------------- McGill University Routine: double MSdNint (double x) Purpose: Nearest integer function Description: This routine returns the integer-valued double nearest x. Specifically, the returned value is floor(x+0.5) for positive x and ceil(x-0.5) for negative x. Parameters: <- double MSdNint Returned integer value -> double x Input value Author / revision: P. Kabal Copyright (C) 1994 $Revision: 1.5 $ $Date: 1994/03/30 14:16:10 $ -------------------------------------------------------------------------*/ static char rcsid[] = "$Id: MSdNint.c 1.5 1994/03/30 AFsp-V2R1 $"; #include /* floor and ceil */ #include double MSdNint (x) double x; { double pint; if (x >= 0.0) pint = floor (x + 0.5); else pint = ceil (x - 0.5); return pint; }