head	1.5;
access;
symbols
	r2_1:1.3
	r2_0:1.3;
locks; strict;
comment	@// @;


1.5
date	94.11.30.15.53.57;	author thoth;	state Exp;
branches;
next	1.4;

1.4
date	94.11.10.18.47.59;	author ljr;	state Exp;
branches;
next	1.3;

1.3
date	94.08.18.13.53.01;	author ljr;	state Exp;
branches;
next	1.2;

1.2
date	94.08.17.02.01.47;	author gmt;	state Exp;
branches;
next	1.1;

1.1
date	94.08.12.21.11.32;	author ljr;	state Exp;
branches;
next	;


desc
@Initial revision
@


1.5
log
@Removed decorative static char[]s.
removed extra RCS Log entry as it was causing duplicate substitutions
upon revision checkin.
@
text
@// Emacs -*- C++ -*-

//      Copyright 1994, Center for Computer Vision and Visualization,
//      University of Florida.  All rights reserved.

// $Log: compat.c,v $
// Revision 1.4  1994/11/10  18:47:59  ljr
// Added IA_NO_RCS_STATIC_DATA guard.
//
// Revision 1.3  1994/08/18  13:53:01  ljr
// Added missing #endif for #ifdef IA_NEED_IRINT
//
// Revision 1.2  1994/08/17  02:01:47  gmt
// Added the RCS Log comment.
// Also wrapped ifdefs around each function so taht they do not exist unless
// they are needed.  These are to match the ifdefs in compat.h.
//

#include <stdlib.h>
#include "compat.h"

#ifdef IA_NEED_AINT
// aint() returns the integral value between x and 0, nearest x
double aint(double x)
{
   return (double)((int)x);
}
#endif

#ifdef IA_NEED_NINT
// nint() converts x into int format rounding to the nearest int value,
// except halfway cases are rounded to the int value larger in magnitude
int nint(double x)
{
   return (x > 0)? (int)(x + .5) : (int)(x - .5);
}
#endif

#ifdef IA_NEED_ANINT
// anint() returns the nearest integral value to x, except halfway cases
// are rounded to the integral value larger in magnitude
double anint(double x)
{
   return (double)((x > 0)? (int)(x + .5) : (int)(x - .5));
}
#endif

#ifdef IA_NEED_RINT
// rint() returns the nearest integral value to x, except halfway cases are
// rounded to an even digit (banker's rounding)
double rint(double x)
{
   return (abs((int)x) % 2)?
      anint(x) : (x+.5 == aint(x+.5))? aint(x) : anint(x);
}
#endif

#ifdef IA_NEED_IRINT
// irint() converts x into int format rounding to the nearest int value,
// except halfway cases are rounded to an even digit (banker's rounding)
int irint(double x)
{
   return (int)((abs((int)x) % 2)?
      anint(x) : (x+.5 == aint(x+.5))? aint(x) : anint(x));
}
#endif
@


1.4
log
@Added IA_NO_RCS_STATIC_DATA guard.
@
text
@a5 6
#ifndef IA_NO_RCS_STATIC_DATA
static char copyright[] = "Copyright 1994, Center for Computer Vision and Visualization,\nUniversity of Florida.  All rights reserved.\n";

static char rcsid[] = "$Id: compat.c,v 1.3 1994/08/18 13:53:01 ljr Exp ljr $";
#endif

d7 3
d14 1
a14 4
// Added the RCS "$Log: compat.c,v $
// Revision 1.3  1994/08/18  13:53:01  ljr
// Added missing #endif for #ifdef IA_NEED_IRINT
//" comment.
@


1.3
log
@Added missing #endif for #ifdef IA_NEED_IRINT
@
text
@d6 1
d9 2
a10 1
static char rcsid[] = "$Id: compat.c,v 1.2 1994/08/17 02:01:47 gmt Exp ljr $";
d13 3
d17 4
a20 1
// Added the RCS "$Log$" comment.
@


1.2
log
@Added the RCS "$Log$" comment.
Also wrapped ifdefs around each function so taht they do not exist unless
they are needed.  These are to match the ifdefs in compat.h.
@
text
@d8 1
a8 1
static char rcsid[] = "$Id: compat.c,v 1.1 1994/08/12 21:11:32 ljr Exp gmt $";
d10 6
a15 1
// $Log$
d64 1
@


1.1
log
@Initial revision
@
text
@d6 1
a6 2
static char copyright[] = "Copyright 1994, Center for Computer Vision and Visual
ization,\nUniversity of Florida.  All rights reserved.\n";
d8 1
a8 1
static char rcsid[] = "$Id: compat.c,v 1.1 1994/08/12 16:43:32 ljr Exp $";
d10 2
d15 1
d21 1
d23 1
d30 1
d32 1
d39 1
d41 1
d49 1
d51 1
@
