-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Open
Labels
LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolProposal
Milestone
Description
Proposal Details
Some computations require floor and ceiling of a rational number.
I propose adding Floor and Ceil methods to big.Rat, which return
the floor and ceiling as a *big.Int respectively.
Pull request #76820
An example use case is computing the Engel expansion:
func toEngel(u *big.Rat) (seq []*big.Int) {
for {
a := new(big.Rat).Inv(u).Ceil()
seq = append(seq, a)
u.Mul(u, new(big.Rat).SetInt(a))
u.Sub(u, big.NewRat(1, 1))
if u.Num().Cmp(big.NewInt(0)) == 0 {
break
}
}
return seq
}
CAFxX and adonovan
Metadata
Metadata
Assignees
Labels
LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolProposal
Type
Projects
Status
Incoming