home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************************
- * *
- * MISC.CPP: Includes some math routines not found in math.h *
- * *
- * Copyright (C) 2000 Andrei Grecu *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- * *
- * If you have questions, bug reports regarding my code please contact me at: *
- * andrei.grecu@aon.at *
- * *
- * Home page: *
- * http://members.aon.at/grxpage/index.htm *
- * *
- **********************************************************************************/
-
- #include "precomp.h"
- #include <math.h>
-
- #include "misc.h"
-
- long round(FLOAT x) {
-
- FLOAT y;
-
- if(x > 0) {
- y = x - int(x);
- if(y >= 0.5) return((long)ceil(x));
- if(y < 0.5) return((long)floor(x));
- }
- else {
- y = int(x) - x;
- if(y >= 0.5) return((long)floor(x));
- if(y < 0.5) return((long)ceil(x));
- }
-
- return(0);
-
- }
-
- signed long band_pass(signed long x) {
-
- if(x > 32767) return(32767);
- else if(x < -32767) return(-32767);
- else return(x);
-
- }
-
- FLOAT positive(FLOAT x) {
-
- if(x > 0) return(x);
- else return(0);
-
- }
-
-