Repository navigation
add scalbn and ilogb methods on floats - #163187
Conversation
| /// Placeholder. | ||
| #[inline] | ||
| #[unstable(feature = "float_exponent_methods", issue = "163184")] | ||
| #[rustc_const_unstable(feature = "float_exponent_methods", issue = "163184")] | ||
| #[must_use = "method returns a new number and does not mutate the original value"] | ||
| pub const fn scalbn(self, exponent: i32) -> f128 { | ||
| intrinsics::scalbn(self, exponent) | ||
| } | ||
|
|
||
| /// Placeholder. |
There was a problem hiding this comment.
Placeholder docs. (I hate that we can't just use macros to define the float types.)
There was a problem hiding this comment.
What could be nice nowadays is putting the docs into one of the macro_rules! attribute macros so you could do something like #[float_docs(ilogb, f128, constant_a = 1234, constant_b = 3.141)]. So the docs can get reused but "go to source" works correctly and the implementations can deviate where necessary.
| /// Placeholder. | ||
| #[inline] | ||
| #[unstable(feature = "float_exponent_methods", issue = "163184")] | ||
| #[rustc_const_unstable(feature = "float_exponent_methods", issue = "163184")] | ||
| #[must_use = "method returns a new number and does not mutate the original value"] | ||
| pub const fn scalbn(self, exponent: i32) -> f16 { | ||
| intrinsics::scalbn(self, exponent) | ||
| } | ||
|
|
||
| /// Placeholder. |
There was a problem hiding this comment.
Placeholder docs. (I hate that we can't just use macros to define the float types.)
| /// Placeholder. | ||
| #[inline] | ||
| #[unstable(feature = "float_exponent_methods", issue = "163184")] | ||
| #[rustc_const_unstable(feature = "float_exponent_methods", issue = "163184")] | ||
| #[must_use = "method returns a new number and does not mutate the original value"] | ||
| pub const fn scalbn(self, exponent: i32) -> f64 { | ||
| intrinsics::scalbn(self, exponent) | ||
| } | ||
|
|
||
| /// Placeholder. |
There was a problem hiding this comment.
Placeholder docs. (I hate that we can't just use macros to define the float types.)
| /// Placeholder. | ||
| #[inline] | ||
| #[unstable(feature = "float_exponent_methods", issue = "163184")] | ||
| #[rustc_const_unstable(feature = "float_exponent_methods", issue = "163184")] | ||
| #[must_use = "method returns a new number and does not mutate the original value"] | ||
| pub const fn scalbn(self, exponent: i32) -> f128 { | ||
| intrinsics::scalbn(self, exponent) | ||
| } | ||
|
|
||
| /// Placeholder. |
There was a problem hiding this comment.
What could be nice nowadays is putting the docs into one of the macro_rules! attribute macros so you could do something like #[float_docs(ilogb, f128, constant_a = 1234, constant_b = 3.141)]. So the docs can get reused but "go to source" works correctly and the implementations can deviate where necessary.
This comment has been minimized.
This comment has been minimized.
|
|
|
Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr Some changes occurred to the CTFE machinery
cc @tgross35 |
There was a problem hiding this comment.
I think the only remaining item is the doc comment then (unless something new pops up), which I'd like to settle on first and can then copy. Or maybe #165773 merges in the meantime and we don't need to copy the comment.
…Jung add `scalbn` and `ilogb` methods on floats tracking issue: rust-lang#163184
|
💔 I suspect this PR failed tests as part of a rollup After fixing the problem, consider running a try job for the failed job before re-approving. Link to failure: #166436 (comment) |
|
This pull request was unapproved. This PR was contained in a rollup (#166436), which was unapproved. |
| /// assert_eq!(3.0_f64.scalbn(4), 3.0 * 2.0_f64.powi(4)); // = 3 * 16 = 48 | ||
| /// assert_eq!(3.0_f64.scalbn(-1), 3.0 * 2.0_f64.powi(-1)); // = 3 * 0.5 = 1.5 |
There was a problem hiding this comment.
With Miri (and who knows, some libcs) the powi here is not exact, so I'll make this match on the answer and put the calculation in the comment.
|
@bors try jobs=test-x86_64-gnu-aux |
add `scalbn` and `ilogb` methods on floats try-job: test-x86_64-gnu-aux
This comment has been minimized.
This comment has been minimized.
|
@bors r=tgross35,RalfJung |
…Jung add `scalbn` and `ilogb` methods on floats tracking issue: rust-lang#163184
…uwer Rollup of 12 pull requests Successful merges: - #166340 (Revert "implement const Iterator for Range - #156216") - #165345 (Remove the 'eq', 'eq_trace', and 'goals_to_obligations' methods from 'At') - #165538 (Supertraits returns Unnormalized) - #165794 (`consider_impl_candidate` tweaks) - #160752 (Avoid inference constraints from opaque blanket impls) - #163187 (add `scalbn` and `ilogb` methods on floats) - #164541 (Add regression test for #152415) - #164543 (Add regression test for #151316) - #165920 (Introduce compute_abi helper and ComputeCallConv trait) - #166313 (Move `rustdoc-ui` tests in the right folder) - #166420 ([rustdoc] Fix search index generation: if crate content didn't change, it should generate the same search index) - #166485 (Allow passing `--exact-match` and `--purge` to `x perf`)
…uwer Rollup of 12 pull requests Successful merges: - rust-lang/rust#166340 (Revert "implement const Iterator for Range - rust-lang/rust#156216") - rust-lang/rust#165345 (Remove the 'eq', 'eq_trace', and 'goals_to_obligations' methods from 'At') - rust-lang/rust#165538 (Supertraits returns Unnormalized) - rust-lang/rust#165794 (`consider_impl_candidate` tweaks) - rust-lang/rust#160752 (Avoid inference constraints from opaque blanket impls) - rust-lang/rust#163187 (add `scalbn` and `ilogb` methods on floats) - rust-lang/rust#164541 (Add regression test for rust-lang/rust#152415) - rust-lang/rust#164543 (Add regression test for rust-lang/rust#151316) - rust-lang/rust#165920 (Introduce compute_abi helper and ComputeCallConv trait) - rust-lang/rust#166313 (Move `rustdoc-ui` tests in the right folder) - rust-lang/rust#166420 ([rustdoc] Fix search index generation: if crate content didn't change, it should generate the same search index) - rust-lang/rust#166485 (Allow passing `--exact-match` and `--purge` to `x perf`)
…uwer Rollup of 12 pull requests Successful merges: - rust-lang/rust#166340 (Revert "implement const Iterator for Range - rust-lang/rust#156216") - rust-lang/rust#165345 (Remove the 'eq', 'eq_trace', and 'goals_to_obligations' methods from 'At') - rust-lang/rust#165538 (Supertraits returns Unnormalized) - rust-lang/rust#165794 (`consider_impl_candidate` tweaks) - rust-lang/rust#160752 (Avoid inference constraints from opaque blanket impls) - rust-lang/rust#163187 (add `scalbn` and `ilogb` methods on floats) - rust-lang/rust#164541 (Add regression test for rust-lang/rust#152415) - rust-lang/rust#164543 (Add regression test for rust-lang/rust#151316) - rust-lang/rust#165920 (Introduce compute_abi helper and ComputeCallConv trait) - rust-lang/rust#166313 (Move `rustdoc-ui` tests in the right folder) - rust-lang/rust#166420 ([rustdoc] Fix search index generation: if crate content didn't change, it should generate the same search index) - rust-lang/rust#166485 (Allow passing `--exact-match` and `--purge` to `x perf`)
View all comments
tracking issue: #163184