|
|
1.1 ! root 1: .\" Copyright (c) 1985 Regents of the University of California. ! 2: .\" All rights reserved. The Berkeley software License Agreement ! 3: .\" specifies the terms and conditions for redistribution. ! 4: .\" ! 5: .\" @(#)floor.3 6.4 (Berkeley) 5/12/86 ! 6: .\" ! 7: .TH FLOOR 3M "May 12, 1986" ! 8: .UC 4 ! 9: .SH NAME ! 10: fabs, floor, ceil, rint \- absolute value, floor, ceiling, and ! 11: round-to-nearest functions ! 12: .SH SYNOPSIS ! 13: .nf ! 14: .B #include <math.h> ! 15: .PP ! 16: .B double floor(x) ! 17: .B double x; ! 18: .PP ! 19: .B double ceil(x) ! 20: .B double x; ! 21: .PP ! 22: .B double fabs(x) ! 23: .B double x; ! 24: .PP ! 25: .B double rint(x) ! 26: .B double x; ! 27: .fi ! 28: .SH DESCRIPTION ! 29: Fabs returns the absolute value |\|x\||. ! 30: .PP ! 31: Floor returns the largest integer no greater than x. ! 32: .PP ! 33: Ceil returns the smallest integer no less than x. ! 34: .PP ! 35: Rint returns the integer (represented as a double precision number) ! 36: nearest x in the direction of the prevailing rounding mode. ! 37: .SH NOTES ! 38: On a VAX, rint(x) is equivalent to adding half to the magnitude ! 39: and then rounding towards zero. ! 40: .PP ! 41: In the default rounding mode, to nearest, ! 42: on a machine that conforms to IEEE 754, ! 43: rint(x) is the integer nearest x with the additional stipulation ! 44: that if |rint(x)\-x|=1/2 then rint(x) is even. ! 45: Other rounding modes can make rint act like floor, or like ceil, ! 46: or round towards zero. ! 47: .PP ! 48: Another way to obtain an integer near x is to declare (in C) ! 49: .RS ! 50: double x;\0\0\0\0 int k;\0\0\0\0k\0=\0x; ! 51: .RE ! 52: Most C compilers round x towards 0 to get the integer k, but ! 53: some do otherwise. ! 54: If in doubt, use floor, ceil, or rint first, whichever you intend. ! 55: Also note that, if x is larger than k can accommodate, the value of ! 56: k and the presence or absence of an integer overflow are hard to ! 57: predict. ! 58: .SH SEE ALSO ! 59: abs(3), ! 60: ieee(3M), ! 61: math(3M)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.