Opened 6 years ago

Closed 5 years ago

#185 closed defect (wontfix)

Add sixth "centered" division operator

Reported by: cowan Owned by: cowan
Priority: major Milestone:
Component: WG1 - Core Keywords:


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

Change History (5)

comment:1 Changed 6 years ago by alexshinn

  • Resolution set to fixed
  • Status changed from new to closed

We voted not to include this.

comment:2 Changed 6 years ago by cowan

  • Resolution fixed deleted
  • Status changed from closed to reopened

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 .

comment:3 Changed 6 years ago by cowan

  • Status changed from reopened to decided

WG1 accepted this proposal.

comment:4 Changed 6 years ago by cowan

  • Owner changed from alexshinn to cowan
  • Status changed from decided to writing

comment:5 Changed 5 years ago by cowan

  • Resolution set to wontfix
  • Status changed from writing to closed

Undone by #278.

Note: See TracTickets for help on using tickets.