[stdlib] implement `bit_ceil` and `bit_floor`
fix #2682
Implementation of bit_ceil is based on c++ bit_ceil
Should we include the reference in doc string or comment in the future?
Should we include the reference in doc string or comment in the future?
@soraros ops yeah you are right. I'll include it in the docstring for now. @laszlokindrat which one do you think is more suitable?
Should we include the reference in doc string or comment in the future?
@soraros ops yeah you are right. I'll include it in the docstring for now. @laszlokindrat which one do you think is more suitable?
I would prefer to not reference external documentation. Can you please just ensure that the docstrings are (more or less) self explanatory?
@laszlokindrat My idea was that performant numerical code can contain a large amount of black magic, thus not very self-explanatory. If we are indeed using an existing implementation (from a paper, libc++, etc) and include a reference to them, it would be less surprising to future maintainers when they see the said magic. If you think a link is not fitting for the doctoring, maybe we could simply leave a comment.
@laszlokindrat I have fixed all the requests. In terms of the reference, I do agree with @soraros in that numerical code does sometime contains "black magic". While these two functions seems pretty ok to understand, there might be functions that has wizardry implementation in the future and adding a reference can definitely help future maintainer. I have taken out the c++ reference. If there is a consent, I can put it back in.
If you think a link is not fitting for the doctoring, maybe we could simply leave a comment.
Yeah, a link within a comment in the implementation is fine, since that's a message to developers working on the stdlib. I just didn't want the generated docs to reference external links (and also, docstrings should explain what the function does, not how). @LJ-9801 could you please do this?
!sync
@laszlokindrat @JoeLoser mojo crash on test_reversed.mojo? test crashes sometime on my M1 mac as well. Most of the time they pass. see 332c152
!sync
✅🟣 This contribution has been merged 🟣✅
Your pull request has been merged to the internal upstream Mojo sources. It will be reflected here in the Mojo repository on the nightly branch during the next Mojo nightly release, typically within the next 24-48 hours.
We use Copybara to merge external contributions, click here to learn more.
Landed in abfdac1a7e78e72e148cfd5dec319649fa1d1ca8! Thank you for your contribution 🎉