This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home.

Ticket 185: Add sixth "centered" division operator

2012-10-05 06:49:38
WG1 - Core
cowan
major
cowan
wontfix
source
closed
2011-05-20 07:35:00
defect

From the Guile manual:

— Scheme Procedure: centered/ x y — Scheme Procedure: centered-quotient x y — Scheme Procedure: centered-remainder x y

These procedures accept two real numbers x and y, where the divisor y must be non-zero. centered-quotient returns the integer q and centered-remainder returns the real number r such that x = q*y + r and -|y/2| <= r < |y/2|. centered/ returns both q and r, and is more efficient than computing each separately.

Note that centered-quotient returns x/y rounded to the nearest integer. When x/y lies exactly half-way between two integers, the tie is broken according to the sign of y. If y > 0, ties are rounded toward positive infinity, otherwise they are rounded toward negative infinity. This is a consequence of the requirement that -|y/2| <= r < |y/2|.

Note that these operators are equivalent to the R6RS operators div0, mod0, and div0-and-mod0.

--Andy Wingo

resolutionfixed
statusnewclosed

We voted not to include this.

resolutionfixed
statusclosedreopened

I'm reopening this ticket based on the arguments below:

AFAIU centered/ is useful when you want to restrict the range of the result of division to be a fixnum, which is useful when implementing Scheme. See http://lists.gnu.org/archive/html/guile-devel/2011-01/msg00136.html .

statusreopeneddecided

WG1 accepted this proposal.

owneralexshinncowan
statusdecidedwriting
resolutionwontfix
statuswritingclosed

Undone by #278.