2 quo - compute integer quotient of a value by a real number
5 quo(x, y, rnd) or x // y
8 If x is a matrix or list, the returned value is a matrix or list v of
9 the same structure for which each element v[[i]] = quo(x[[i]], y, rnd).
11 If x is an xx-object or x is not an object and y is an xx-object,
12 this function calls the user-defined function xx_quo(x, y, rnd);
13 the types of arguments and returned value are as required by the
14 definition of xx_quo().
16 If neither x nor y is an object, and x is not a matrix or list:
18 x number (real or complex)
20 rnd integer, defaults to config("quo")
25 If x is real or complex and y is zero, quo(x, y, rnd) returns zero.
27 If x is complex, quo(x, y, rnd) returns
28 quo(re(x), y, rnd) + quo(im(x), y, rnd) * 1i.
30 In the following it is assumed that x is real and y is nonzero.
32 If x/y is an integer quo(x, y, rnd) returns x/y.
34 If x is real, y nonzero and x/y is not an integer, x // y returns
35 one of the two integers v for which abs(x/y - v) < 1. Which
36 integer is returned is controlled by rnd as follows:
38 rnd sign of x/y - v Description of rounding
40 0 + down, towards minus infinity
41 1 - up, towards infinity
42 2 sgn(x/y) towards zero
48 8 to nearest even integer
49 9 to nearest odd integer
50 10 even if x/y > 0, otherwise odd
51 11 odd if x/y > 0, otherwise even
52 12 even if y > 0, otherwise odd
53 13 odd if y > 0, otherwise even
54 14 even if x > 0, otherwise odd
55 15 odd if x > 0, otherwise even
57 16-31 to nearest integer when this
58 is uniquely determined;
59 otherwise, when x/y is a
61 rnd replaced by rnd & 15
63 NOTE: Blank entries in the table above indicate that the
64 description would be complicated and probably not of
67 The C language method of modulus and integer division is:
74 print quo(11,5,0), quo(11,5,1), quo(-11,5,2), quo(-11,-5,3)
77 print quo(12.5,5,16), quo(12.5,5,17), quo(12.5,5,24), quo(-7.5,-5,24)
84 void quovalue(VALUE *x, VALUE *y, VALUE *rnd, VALUE *result)
85 NUMBER *qquo(NUMBER *x, NUMBER *y, long rnd)
90 ## Copyright (C) 1999 Landon Curt Noll
92 ## Calc is open software; you can redistribute it and/or modify it under
93 ## the terms of the version 2.1 of the GNU Lesser General Public License
94 ## as published by the Free Software Foundation.
96 ## Calc is distributed in the hope that it will be useful, but WITHOUT
97 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
98 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
99 ## Public License for more details.
101 ## A copy of version 2.1 of the GNU Lesser General Public License is
102 ## distributed with calc under the filename COPYING-LGPL. You should have
103 ## received a copy with calc; if not, write to Free Software Foundation, Inc.
104 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
106 ## @(#) $Revision: 30.1 $
107 ## @(#) $Id: quo,v 30.1 2007/03/16 11:10:42 chongo Exp $
108 ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/quo,v $
110 ## Under source code control: 1995/09/18 04:01:44
111 ## File existed as early as: 1995
113 ## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
114 ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/