about summary refs log tree commit diff
path: root/src/libcore/num
AgeCommit message (Collapse)AuthorLines
2018-02-11Make primitive types docs relevant (unsigned)Antoni Boucher-735/+815
2018-02-11Make primitive types docs relevantGuillaume Gomez-937/+1016
2018-02-10Correct a few stability attributesOliver Middleton-3/+3
2018-02-01Use constant for 180/π in to_degreesvarkor-1/+6
The current `f32|f64.to_degrees` implementation uses a division to calculate 180/π, which causes a loss of precision. Using a constant is still not perfect (implementing a maximally-precise algorithm would come with a high performance cost), but improves precision with a minimal change.
2018-01-24Auto merge of #46931 - clarcharr:float_bits_core, r=alexcrichtonbors-50/+69
Expose float from_bits and to_bits in libcore. These methods have no dependencies on libm and thus should be offered in libcore.
2018-01-07Rollup merge of #46947 - tspiteri:checked-div-rem-none, r=frewsxcvkennytm-4/+4
doc: improve None condition doc for `checked_div` and `checked_rem` This commit improves the condition mentioned in the docs for which `checked_div` and `checked_rem` return `None`. For signed division, the commit changes "the operation results in overflow" to "the division results in overflow", otherwise there is room for misinterpretation for `checked_rem`: Without considering overflow, `MIN % -1` would be simply zero, allowing the misinterpretation that "the operation" does not result in overflow in this case. This ambiguity is removed using "when the division results in overflow". For unsigned division, the condition for `None` should be simply when `rhs == 0`, as no other overflow is possible.
2017-12-30Optimise min/maxvarkor-4/+4
Swapping the conditions generates more efficient x86 assembly. See https://github.com/rust-lang/rust/pull/46926#issuecomment-354567412.
2017-12-26Rollup merge of #46986 - nvzqz:basic-usage, r=steveklabnikkennytm-0/+8
Add "Basic Usage" to int min_value and max_value docs This adds "Basic Usage:" to the docs of `min_value` and `max_value`, which makes it consistent with docs of other integer methods.
2017-12-26Rollup merge of #46933 - clarcharr:float_docs, r=steveklabnikkennytm-2/+12
Make core::f32/f64 docs match std. For some reason these weren't in sync.
2017-12-24Add "Basic Usage" to int min_value, max_value docsNikolai Vazquez-0/+8
2017-12-23Move Bits constraints to RawFloat::RawBitsClar Charr-5/+20
2017-12-22Expose float from_bits and to_bits in libcore.Clar Charr-47/+51
2017-12-22doc: improve None condition doc for `checked_div` and `checked_rem`Trevor Spiteri-4/+4
2017-12-21Make core::f32/f64 docs match std.Clar Charr-2/+12
2017-12-22Rollup merge of #46898 - tspiteri:int-overflow-not-underflow, r=steveklabnikkennytm-9/+9
docs: do not call integer overflows as underflows In the API docs, integer overflow is sometimes called underflow. Underflow is really when the magnitude of a floating-point number is too small so the number underflows to subnormal or zero. With integers it is always overflow, even if the expected result is less than the minimum number that can be represented.
2017-12-22Rollup merge of #46820 - nodakai:simplify-int-impl, r=alexcrichtonkennytm-151/+52
libcore/num/mod.rs: simplify the int_impl! macro. We can simply use generic intrinsics since cd1848a1a6 by @alexcrichton Also, minimize unsafe blocks.
2017-12-21docs: do not call integer overflows as underflowsTrevor Spiteri-9/+9
2017-12-19libcore/num/mod.rs: simplify the int_impl! macro.NODA, Kai-151/+52
We can simply use generic intrinsics since cd1848a1a6 Also, minimize unsafe blocks. Signed-off-by: NODA, Kai <nodakai@gmail.com>
2017-12-17Display binary notation for numeric swap_bytes methods.Corey Farwell-6/+12
This better illustrates what's happening to the bits behind the scenes.
2017-12-12Auto merge of #46411 - rillian:str_ascii, r=kennytmbors-6/+6
Mark ascii methods on primitive types stable in 1.23.0 not 1.21.0. The ascii_methods_on_intrinsics feature stabilization didn't land in time for 1.21.0. Update the annotation so the documentation is correct about when these methods became available.
2017-12-03Consistent parameter name for numeric ‘checked’ operations.Corey Farwell-69/+69
Some checked operations use `rhs` as a parameter name, and some use `other`. For the sake of consistency, unify everything under the `rhs` name. Fixes https://github.com/rust-lang/rust/issues/46308.
2017-12-02Mark ascii methods on primitive types stable in 1.23.0.Ralph Giles-6/+6
The ascii_methods_on_intrinsics feature stabilization didn't land in time for 1.21.0. Update the annotation so the documentation is correct about when these methods became available.
2017-11-29Rollup merge of #46287 - SimonSapin:stable-constness, r=aturonkennytm-4/+0
Stabilize const-calling existing const-fns in std Fixes #46038
2017-11-29Rollup merge of #46077 - LukasKalbertodt:stabilize-ascii-ctype, r=alexcrichtonkennytm-10/+10
Stabilize some `ascii_ctype` methods As discussed in #39658, this PR stabilizes those methods for `u8` and `char`. All inherent `ascii_ctype` for `[u8]` and `str` are removed as we prefer the more explicit version `s.chars().all(|c| c.is_ascii_())`. This PR doesn't modify the `AsciiExt` trait. There, the `ascii_ctype` methods are still unstable. It is planned to remove those in the future (I think). I had to modify some code in `ascii.rs` to properly implement `AsciiExt` for all types. Fixes #39658.
2017-11-28Change `since` attribute from ctype methods from 1.23 to 1.24Lukas Kalbertodt-10/+10
The changes didn't land in time for 1.23 and stabilizations won't be backported to beta.
2017-11-26Stabilize const-calling existing const-fns in stdSimon Sapin-4/+0
Fixes #46038
2017-11-24Expand docs of <$Int>::from_str_radix, based on that of char::to_digitSimon Sapin-0/+18
2017-11-18Stabilize `ascii_ctype` methods for `u8` and `char`Lukas Kalbertodt-10/+10
The feature of those methods was renamed to "ascii_ctype_on_intrinsics".
2017-11-14Fixed several pulldown warnings when documenting libstd.kennytm-1/+1
2017-11-05Auto merge of #44042 - LukasKalbertodt:ascii-methods-on-instrinsics, ↵bors-0/+644
r=alexcrichton Copy all `AsciiExt` methods to the primitive types directly in order to deprecate it later **EDIT:** [this PR is ready now](https://github.com/rust-lang/rust/pull/44042#issuecomment-333883548). I edited this post to reflect the current status of discussion, which is (apart from code review) pretty much settled. --- This is my current progress in order to prepare stabilization of #39658. As discussed there (and in #39659), the idea is to deprecated `AsciiExt` and copy all methods to the type directly. Apparently there isn't really a reason to have those methods in an extension trait¹. ~~This is **work in progress**: copy&pasting code while slightly modifying the documentation isn't the most exciting thing to do. Therefore I wanted to already open this WIP PR after doing basically 1/4 of the job (copying methods to `&[u8]`, `char` and `&str` is still missing) to get some feedback before I continue. Some questions possibly worth discussing:~~ 1. ~~Does everyone agree that deprecating `AsciiExt` is a good idea? Does everyone agree with the goal of this PR?~~ => apparently yes 2. ~~Are my changes OK so far? Did I do something wrong?~~ 3. ~~The issue of the unstable-attribute is currently set to 0. I would wait until you say "Ok" to the whole thing, then create a tracking issue and then insert the correct issue id. Is that ok?~~ 4. ~~I tweaked `eq_ignore_ascii_case()`: it now takes the argument `other: u8` instead of `other: &u8`. The latter was enforced by the trait. Since we're not bound to a trait anymore, we can drop the reference, ok?~~ => I reverted this, because the interface has to match the `AsciiExt` interface exactly. ¹ ~~Could it be that we can't write `impl [u8] {}`? This might be the reason for `AsciiExt`. If that is the case: is there a good reason we can't write such an impl block? What can we do instead?~~ => we couldn't at the time this PR was opened, but Simon made it possible. /cc @SimonSapin @zackw
2017-11-04Use Add::add for overflow checks instead of [rustc_inherit_overflow_checks]Scott McMurray-2/+3
2017-11-03Fix #18604: next_power_of_two should panic on overflowScott McMurray-0/+1
2017-11-03Mark several ascii methods as unstable againLukas Kalbertodt-10/+30
We don't want to stabilize them now already. The goal of this set of commits is just to add inherent methods to the four types. Stabilizing all of those methods can be done later.
2017-11-03Fix lists in doc comments for ascii methods of u8 and charLukas Kalbertodt-2/+4
2017-11-03Add missing space in match armLukas Kalbertodt-2/+2
2017-11-03Tweak documentation for `u8::eq_ignore_ascii_case()`Lukas Kalbertodt-2/+1
2017-11-03Revert signature of eq_ignore_ascii_case() to originalLukas Kalbertodt-2/+2
Since the methods on u8 directly will shadow the AsciiExt methods, we cannot change the signature without breaking everything. It would have been nice to take `u8` as argument instead of `&u8`, but we cannot break stuff! So this commit reverts it to the original `&u8` version.
2017-11-03Make ascii methods on u8 insta-stableLukas Kalbertodt-48/+16
Those methods will shadow the methods of `AsciiExt`, so if we don't make them insta-stable, everyone will hitting stability errors. It is fine adding those as stable, because they are just being moved around [according to sfackler][1]. OPEN QUESTION: this commit also stabilizes the `AsciiExt` methods that were previously feature gated by the `ascii_ctype` feature. Maybe we don't want to stablilize those yet. [1]: https://github.com/rust-lang/rust/pull/44042#issuecomment-329939279
2017-11-03Add all methods of AsciiExt to u8 directlyLukas Kalbertodt-0/+655
This is the first step in order to deprecate AsciiExt. Since this is a WIP commit, there is still some code duplication (notably the static arrays) that will be removed later.
2017-10-26Bump to 1.23 and update bootstrapAlex Crichton-4/+4
This commit updates the bootstrap compiler, bumps the version to 1.23, updates Cargo, updates books, and updates crates.io dependencies
2017-09-30Auto merge of #44936 - Mark-Simulacrum:rollup, r=Mark-Simulacrumbors-0/+12
Rollup of 15 pull requests - Successful merges: #44124, #44287, #44320, #44694, #44708, #44794, #44797, #44824, #44836, #44840, #44845, #44854, #44889, #44900, #44903 - Failed merges:
2017-09-29Rollup merge of #44287 - Eh2406:master, r=aturonMark Simulacrum-0/+12
Allow T op= &T for built-in numeric types T v2 Manually rebase of @Migi https://github.com/rust-lang/rust/pull/41336
2017-09-29Auto merge of #44174 - jimmycuadra:try-from-infallible, r=sfacklerbors-29/+21
Add blanket TryFrom impl when From is implemented. Adds `impl<T, U> TryFrom<T> for U where U: From<T>`. Removes `impl<'a, T> TryFrom<&'a str> for T where T: FromStr` (originally added in #40281) due to overlapping impls caused by the new blanket impl. This removal is to be discussed further on the tracking issue for TryFrom. Refs #33417. /cc @sfackler, @scottmcm (thank you for the help!), and @aturon
2017-09-29Fix more TryFrom impls for integers.Jimmy Cuadra-4/+4
2017-09-29Simplify implementation of From<Infallible> for TryFromIntError.Jimmy Cuadra-2/+3
2017-09-28Remove conflicting TryFrom impls on 32-bit targets.Jimmy Cuadra-2/+2
2017-09-23Add back mistakenly removed numeric conversions.Jimmy Cuadra-4/+4
2017-09-16change #![feature(const_fn)] to specific gatesAlex Burka-0/+4
2017-09-04Removed the incorrect documentation for from_strMax Comstock-1/+0
2017-09-03Manuall rebase of @Migi pull/41336Eh2406-0/+12