?? floor.c
字號:
#ifndef lintstatic char *sccsid ="@(#)floor.c 1.3 (ULTRIX) 4/17/86";#endif lint/************************************************************************ * * * Copyright (c) 1986 by * * Digital Equipment Corporation, Maynard, MA * * All rights reserved. * * * * This software is furnished under a license and may be used and * * copied only in accordance with the terms of such license and * * with the inclusion of the above copyright notice. This * * software or any other copies thereof may not be provided or * * otherwise made available to any other person. No title to and * * ownership of the software is hereby transferred. * * * * This software is derived from software received from the * * University of California, Berkeley, and from Bell * * Laboratories. Use, duplication, or disclosure is subject to * * restrictions under license agreements with University of * * California and with AT&T. * * * * The information in this software is subject to change without * * notice and should not be construed as a commitment by Digital * * Equipment Corporation. * * * * Digital assumes no responsibility for the use or reliability * * of its software on equipment which is not supplied by Digital. * * * ************************************************************************//************************************************************************** Modification History** David Metsky 14-Jan-86** 001 Replaced old version with BSD 4.3 version as part of upgrade** Based on: floor.c 4.2 9/11/85**************************************************************************//* * floor and ceil-- greatest integer <= arg * (resp least >=) */double modf();doublefloor(d)double d;{ double fract; if (d<0.0) { d = -d; fract = modf(d, &d); if (fract != 0.0) d += 1; d = -d; } else modf(d, &d); return(d);}doubleceil(d)double d;{ return(-floor(-d));}/* * algorithm for rint(x) in pseudo-pascal form ... * * real rint(x): real x; * ... delivers integer nearest x in direction of prevailing rounding * ... mode * const L = (last consecutive integer)/2 * = 2**55; for VAX D * = 2**52; for IEEE 754 Double * real s,t; * begin * if x != x then return x; ... NaN * if |x| >= L then return x; ... already an integer * s := copysign(L,x); * t := x + s; ... = (x+s) rounded to integer * return t - s * end; * * Note: Inexact will be signaled if x is not an integer, as is * customary for IEEE 754. No other signal can be emitted. */#ifdef VAXstatic long Lx[] = {0x5c00,0x0}; /* 2**55 */#define L *(double *) Lx#else /* IEEE double */static double L = 4503599627370496.0E0; /* 2**52 */#endifdoublerint(x)double x;{ double s,t,one = 1.0,copysign();#ifndef vax if (x != x) /* NaN */ return (x);#endif if (copysign(x,one) >= L) /* already an integer */ return (x); s = copysign(L,x); t = x + s; /* x+s rounded to integer */ return (t - s);}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -