Repository navigation
Tracking Issue for int_roundings #88581
Copy link
Copy link
Open
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Description
Feature gate: #![feature(int_roundings)]
This is a tracking issue for the div_floor, div_ceil, next_multiple_of, and checked_multiple_of methods on all integer types.
Public API
impl {integer} {
#[unstable]
pub const fn div_floor(self, rhs: Self) -> Self;
}
impl {signed integer} {
#[unstable]
pub const fn div_ceil(self, rhs: Self) -> Self;
#[unstable]
pub const fn next_multiple_of(self, rhs: Self) -> Self;
#[unstable]
pub const fn checked_next_multiple_of(self, rhs: Self) -> Option<Self>;
}
impl {unsigned integer} {
#[stable(since = "1.73.0")]
pub const fn div_ceil(self, rhs: Self) -> Self;
#[stable(since = "1.73.0")]
pub const fn next_multiple_of(self, rhs: Self) -> Self;
#[stable(since = "1.73.0")]
pub const fn checked_next_multiple_of(self, rhs: Self) -> Option<Self>;
}Steps / History
- Implement int_roundings (div_floor, div_ceil, next_multiple_of, checked_next_multiple_of) #88582
- regression: int_roundings conflicts with existing APIs #88971
- Temporarily rename int_roundings functions to avoid conflicts #89184
- Try all stable method candidates first before trying unstable ones #90329
- Revert "Temporarily rename int_roundings functions to avoid conflicts" #91141
- Update
int_roundingsmethods from feedback #95359 - Partially stabilize
int_roundings#94455
Unresolved Questions
- None yet.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Activity
Rollup merge of rust-lang#88582 - jhpratt:int_roundings, r=joshtriplett
Auto merge of rust-lang#88596 - m-ou-se:rollup-cidzt4v, r=m-ou-se
fourbytes commentedon Sep 3, 2021
Just updated to the latest nightly, looks like this feature breaks the num-bigint crate.
error[E0658]: use of unstable library feature 'int_roundings'
jhpratt commentedon Sep 3, 2021
That is considered acceptable breakage. Per RFC 1105, adding an inherent impl is a minor change.
rust: use explicitily Integer::div_ceil
rust: use explicitily Integer::div_ceil
rust: use explicitily Integer::div_ceil
Merge #219
Merge #219
rust: use explicitily Integer::div_ceil
210 remaining items
Auto merge of rust-lang#130002 - orlp:better-div-floor-ceil, r=thomcc
Auto merge of #130002 - orlp:better-div-floor-ceil, r=thomcc
Auto merge of #130002 - orlp:better-div-floor-ceil, r=thomcc
thaliaarchi commentedon Nov 23, 2024
I am interested in this being fleshed out, so I surveyed the methods. The following division/remainder methods are not implemented. For ceiling and floored rounding, there is no
rem_*analogues todiv_*and none of the versions that control overflow and wrapping. Additionally, there is no Euclidean saturating division or any saturating remainders.rem_{ceil,floor}saturating_rem,saturating_{div,rem}_{ceil,euclid,floor}wrapping_{div,rem}_{ceil,floor}checked_{div,rem}_{ceil,floor}overflowing_{div,rem}_{ceil,floor}strict_{div,rem}_{ceil,floor}(Tracking Issue for arithmetic that panics on overflow (strict_*operations) #118260)I maintain a document tracking rounding of division and modulo across languages, which may be a useful reference.
nxsaken commentedon Jul 4, 2025
Is there something that keeps this feature from being stabilized?
orlp commentedon Jul 4, 2025
@nxsaken I for one would strongly recommend we implement
rem_floorandrem_ceilas counterparts to thedivs. Especially becauserem_flooris the remainder you almost always want.cuviper commentedon Jul 4, 2025
The signed methods are still unstable too.
Gnurou commentedon Aug 3, 2025
While
prev_multiple_ofcan be emulated on signed types by passing a negative parameter, that option is not available for unsigned types. Having this method would be useful for e.g. value alignment and is also good API symmetry IMHO.ronnodas commentedon Aug 4, 2025
Consider
unsigned_abs(), as ina.prev_multiple_of(b.unsigned_abs())RES-518: add ceil_div / floor_div — explicit-rounding integer division (
fix(mcp): reverte o div_ceil — eu quebrei codigo que funcionava
fix(claude-bridge): the panel and hover both date and gate on the num…
fix(claude-bridge): a failed usage poll keeps the last good numbers o…