Repository navigation
add scalbn and ilogb methods on floats - #163187
folkertdev wants to merge 2 commits into
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.
|
Fyi it looks like the Miri commit was dropped? |
|
I did some squashing but all the code should still be there? |
|
@bors r=tgross35,RalfJung |
…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
View all comments
tracking issue: #163184