File:  [MW Coherent from dump] / coherent / b / lib / libc / crt / i386 / modf.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:35 2019 UTC (7 years ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

/*
 * libc/crt/modf.c
 */

/*
 * double
 * modf(real, dp)
 * double real, *dp;
 *
 * modf() finds g = greatest integer <= real,
 * then stores g through dp and returns real - g.
 * This version uses a machine dependent subroutine
 *	double _modf(real, dp, e)
 * which assumes real >= 0, 1 <= e = exponent(real) <= DMBITS+1,
 * where DMBITS is the number of mantissa bits in a double.
 */

#if	_IEEE
#define	DEBITS	11
#define	DMBITS	52
#define	FEBITS	 8
#define	FMBITS	23
#endif

#if	_DECVAX
#define	DEBITS	 8
#define	DMBITS	55
#define	FEBITS	 8
#define	FMBITS	23
#endif

extern	double	_modf();
extern	double	frexp();

double
modf(d, dp) double d; register double *dp;
{
	int e;

 	frexp(d, &e);
	if (e >= DMBITS+1) {			/* very large d */
		*dp = d;
		return 0.0;
	} else if (e <= 0) {			/* -1. < d < 1. */
		*dp = 0.0;
		return d;
	} else if (d >= 0.0)
		return _modf(d, dp, e);		/* d >= 0., 1 <= e < DMBITS+1 */

	/* d is negative. */
	d = _modf(-d, dp, e);
	*dp = -*dp;
	return -d;
}

/* end of modf.c */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.