blob: cd462806aa4c84b3d676bfb7c58cd133304f2d0c [file] [log] [blame]
/*************************************************************************/
/* */
/* Copyright (c) 1994 Stanford University */
/* */
/* All rights reserved. */
/* */
/* Permission is given to use, copy, and modify this software for any */
/* non-commercial purpose as long as this copyright notice is not */
/* removed. All other uses, including redistribution in whole or in */
/* part, are forbidden without prior written permission. */
/* */
/* This software is provided with absolutely no warranty and no */
/* support. */
/* */
/*************************************************************************/
/*************************************************************************
* *
* macros.h: general C macros *
* *
*************************************************************************/
#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
#define ABS(X) ((X) > 0 ? (X) : -(X))
#define SIGN(X) ((X) > 0 ? 1 : -1)
#define NINT(X) (int)((X)+0.5) /* flt X>=0*/
#define ROUNDDOWN(X) (int)(X) /* flt X>=0*/
#define ROUNDUP(X) ((X) == (int)(X) ? (int)(X) : (int)(X)+1) /* flt X>=0*/
#define STEPDOWN(X) ((X) == (int)(X) ? (int)(X)-1 : (int)(X)) /* flt X>=0*/
#define STEPUP(X) ((int)(X)+1) /* flt X>=0*/
#define NLONG(X) (long)((X)+0.5) /* flt X>=0*/
#define HALF(X) ((X)>>1) /* int X>=0*/
#define FRACT(X) ((X)-(int)(X)) /* flt X>=0*/