Metropoli BBS
VIEWER: ceil.c MODE: TEXT (ASCII)
/* Copyright (C) 1996 by Thomas Glen Smith.  All Rights Reserved. */
/* ceil APL2 V1.0.0 ****************************************************
* Returns the next higher integer, e.g. for 3.14, returns 4.00, and    *
* for -3.14, returns -3.00.                                            *
***********************************************************************/
#define INCLUDES 0
#include "includes.h"
double ceil(num)
double num;
{
	Floor; Mod;
	extern double fuzz;
	double rem,sign;

	rem = mod(num *= sign = num >= 0.0 ? 1.0 : -1.0, 1.0);
	if (rem < fuzz)
		return(sign * (num - rem));
	else	return(floor(sign * num)+1.0);
}
[ RETURN TO DIRECTORY ]