-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Correct fns exp2 that were calling exp #22076
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
Conversation
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
Nice catch! It seem like all of these functions should have some basic tests to protect against issues like this, a few have such tests (e.g. If you're feeling energetic it would be great to add some tests for some of the other functions, but this is definitely not necessary in this patch. |
@huonw I've added some tests for |
Ug. See #22030 which is documenting float. Sounds like you're working on the same thing. Probably don't want to be duplicating each others work...Maybe we should check to see if one has better examples... |
@mdinger I didn't get too far with the documentation, I stopped when I hit this bug, so you've got better examples for the docs. It's so funny that we both found this within hours!!! |
Agreed. FYI, I'm working from the top down so if you decide to submit a PR against it, start at the bottom and work up. I typically only do a few examples day so it may take a few more days to finish. Then I have to test it. |
@bors r+ 8379 Thanks |
I was working on adding examples to the documentation in `std::num::Float`. I got to `exp2`, which says "Returns 2 raised to the power of the number, `2^(self)`." So I tried running this code: ``` use std::num::Float; #[test] fn test_exp2() { assert_eq!(32.0, 5.0.exp2()); } ``` and it resulted in a failure of `(left: `32`, right: `148.413159`)`. That 148.413159 is the value for e^5, which is `exp()`, not `exp2()`. Sure enough, `exp2` is calling `exp` and shouldn't be, looks like a copy-paste error. I haven't added any tests for this since it's unlikely to break again, but I will happily do so if people think that would be a good idea. The doc examples are coming :) I scanned through the other functions in these files for similar sorts of errors and didn't notice any.
Building on #22076, I've added some tests for stable methods in f32 and f64 that didn't have any before. Please let me know if there are any improvements I can make, and I am happy to make them! 📬
Building on rust-lang#22076, I've added some tests for stable methods in f32 and f64 that didn't have any before. Please let me know if there are any improvements I can make, and I am happy to make them! 📬
Fixes #22080.
I was working on adding examples to the documentation in
std::num::Float
. I got toexp2
, which says "Returns 2 raised to the power of the number,2^(self)
."So I tried running this code:
and it resulted in a failure of
(left:
32, right:
148.413159)
. That 148.413159 is the value for e^5, which isexp()
, notexp2()
.Sure enough,
exp2
is callingexp
and shouldn't be, looks like a copy-paste error.I haven't added any tests for this since it's unlikely to break again, but I will happily do so if people think that would be a good idea. The doc examples are coming :)
I scanned through the other functions in these files for similar sorts of errors and didn't notice any.