home *** CD-ROM | disk | FTP | other *** search
- /* This source file is part of the LynxLib miscellaneous library by
- Robert Fischer, and is Copyright 1990 by Robert Fischer. It costs no
- money, and you may not make money off of it, but you may redistribute
- it. It comes with ABSOLUTELY NO WARRANTY. See the file LYNXLIB.DOC
- for more details.
- To contact the author:
- Robert Fischer \\80 Killdeer Rd \\Hamden, CT 06517 USA
- (203) 288-9599 fischer-robert@cs.yale.edu */
-
- unsigned round_down(i, nearest)
- unsigned i;
- unsigned nearest;
- {
- return i - (i % nearest);
- }
- /* ----------------------------------------------------------- */
- unsigned round_up(i, nearest)
- unsigned i;
- unsigned nearest;
- {
- i += nearest - 1;
- return i - (i % nearest);
- }
- /* ----------------------------------------------------------- */
- int roundup_div(a, b)
- /* Returns a/b rounded up */
- {
- return (a + b - 1) / b;
- }
- /* ----------------------------------------------------------- */
- int round_div(a, b)
- /* Returns a/b rounded to nearest integer */
- {
- return (a + b/2) / b;
- }
- /* ----------------------------------------------------------- */
-