Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document rounding in std::time::Duration's subsec_millis etc. #52263

Closed
sunfishcode opened this issue Jul 11, 2018 · 1 comment
Closed

Document rounding in std::time::Duration's subsec_millis etc. #52263

sunfishcode opened this issue Jul 11, 2018 · 1 comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@sunfishcode
Copy link
Member

In std::time::Duration's documentation, it's stated how as_secs rounds, however it's not stated how sunsec_millis and subsec_micros round.

In the implementations:

pub const fn subsec_millis(&self) -> u32 { self.nanos / NANOS_PER_MILLI }

they round toward zero.

@sfackler sfackler added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Jul 11, 2018
@kennytm kennytm added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Jul 11, 2018
@fintelia
Copy link
Contributor

The same change should also probably be made to the (currently unstable) Duration::as_millis and Duration::as_micros methods. They round the same way.

bors added a commit that referenced this issue Jul 15, 2018
…r=joshtriplett

Document rounding down in std::time::Durations's subsec_millis etc.

Now also the documentations of `subsec_millis`, `subsec_micros`, `as_millis` and `as_micros` make clear that the fractional nanosecond component is rounded down to whole units.

Fixed #52263
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

4 participants