about summary refs log tree commit diff
path: root/src/libcore/num
AgeCommit message (Collapse)AuthorLines
2015-11-06Remove stability annotations from trait impl itemsVadim Petrochenkov-1/+0
Remove `stable` stability annotations from inherent impls
2015-11-01Auto merge of #29316 - GBGamer:change-unchecked-div-generic, r=eddybbors-20/+343
Similarly to the simd intrinsics. I believe this is a better solution than #29288, and I could implement it as well for overflowing_add/sub/mul. Also rename from udiv/sdiv to div, and same for rem.
2015-10-31Check unchecked_div|rem's specialisationNicholas Mazzuca-20/+343
Similarly to the simd intrinsics.
2015-10-29Auto merge of #29129 - cuviper:impl-from-for-floats, r=alexcrichtonbors-3/+24
This is a spiritual successor to #28921, completing the "upcast" idea from rust-num/num#97.
2015-10-28Comment how the significand limits lossless int->float conversionJosh Stone-0/+4
2015-10-23Make `{Default, From, FromIterator, One, Zero}` well-formedAndrew Paseltiner-2/+2
Using these traits in an object context previously resulted in an RFC 1214 warning.
2015-10-17Implement conversion traits for primitive float typesJosh Stone-3/+20
2015-10-17`other` should be called `other`, not `v`.Michael Howell-8/+8
2015-10-15Auto merge of #29050 - rkruppe:dec2flt-lonely-sign, r=alexcrichtonbors-1/+6
Fixes #29042
2015-10-15Auto merge of #28921 - petrochenkov:intconv, r=alexcrichtonbors-0/+43
Part of https://github.com/rust-lang/rfcs/pull/1218#issuecomment-146615171 r? @aturon
2015-10-15Implement conversion traits for primitive integer typesVadim Petrochenkov-0/+43
2015-10-14Reject "+" and "-" when parsing floats.Robin Kruppe-1/+6
Fixes #29042
2015-10-08Auto merge of #28900 - cristicbz:typos, r=alexcrichtonbors-4/+4
I found these automatically, but fixed them manually to ensure the semantics are correct. I know things like these are hardly important, since they only marginally improve clarity. But at least for me typos and simple grammatical errors trigger an---unjustified---sense of unprofessionalism, despite the fact that I make them all the time and I understand that they're the sort of thing that is bound to slip through review. Anyway, to find most of these I used: * `ag '.*//.*(\b[A-Za-z]{2,}\b) \1\b'` for repeated words * `ag '\b(the|this|those|these|a|it) (a|the|this|those|these|it)\b'` to find constructs like 'the this' etc. many false positives, but not too hard to scroll through them to actually find the mistakes. * `cat ../../typos.txt | paste -d'|' - - - - - - - - - - - - - - - - - - - - - - | tr '\n' '\0' | xargs -0 -P4 -n1 ag`. Hacky way to find misspellings, but it works ok. I got `typos.txt` from [Wikipedia](https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines) * `ag '.*//.* a ([ae][a-z]|(o[^n])|(i[a-rt-z]))'` to find places where 'a' was followed by a vowel (requiring 'an' instead). I also used a handful more one off regexes that are too boring to reproduce here.
2015-10-08typos: fix a grabbag of typos all over the placeCristi Cobzarenco-4/+4
2015-10-08Auto merge of #28826 - arthurprs:leading_plus, r=alexcrichtonbors-40/+41
Closes #27580
2015-10-07core: Derive Default for Wrapping<T>Cristi Cobzarenco-1/+1
2015-10-05Fix doc typo in num::{f32,f64}.Jed Davis-2/+2
2015-10-03integer parsing should accept leading plusarthurprs-40/+41
2015-09-20Reorganize core::num internalsRobin Kruppe-73/+98
Move private bignum module to core::num, because it is not only used in flt2dec. Extract private 80-bit soft-float into new core::num module for the same reason.
2015-09-04Fix for issue #28012: pow overflow inconsistencyPeter Reid-15/+11
Overflows in integer pow() computations would be missed if they preceded a 0 bit of the exponent being processed. This made calls such as 2i32.pow(1024) not trigger an overflow.
2015-09-03Elide lifetimes in libcoreManish Goregaokar-7/+7
2015-08-26Make iter::order functions into methods on IteratorSteven Fackler-3/+1
This does cause some breakage due to deficiencies in resolve - `path::Components` is both an `Iterator` and implements `Eq`, `Ord`, etc. If one calls e.g. `partial_cmp` on a `Components` and passes a `&Components` intending to target the `PartialOrd` impl, the compiler will select the `partial_cmp` from `Iterator` and then error out. I doubt anyone will run into breakage from `Components` specifically, but we should see if there are third party types that will run into issues. `iter::order::equals` wasn't moved to `Iterator` since it's exactly the same as `iter::order::eq` but with an `Eq` instead of `PartialEq` bound, which doensn't seem very useful. I also updated `le`, `gt`, etc to use `partial_cmp` which lets us drop the extra `PartialEq` bound. cc #27737
2015-08-22Auto merge of #27871 - alexcrichton:stabilize-libcore, r=aturonbors-110/+126
These commits move libcore into a state so that it's ready for stabilization, performing some minor cleanup: * The primitive modules for integers in the standard library were all removed from the source tree as they were just straight reexports of the libcore variants. * The `core::atomic` module now lives in `core::sync::atomic`. The `core::sync` module is otherwise empty, but ripe for expansion! * The `core::prelude::v1` module was stabilized after auditing that it is a subset of the standard library's prelude plus some primitive extension traits (char, str, and slice) * Some unstable-hacks for float parsing errors were shifted around to not use the same unstable hacks (e.g. the `flt2dec` module is now used for "privacy"). After this commit, the remaining large unstable functionality specific to libcore is: * `raw`, `intrinsics`, `nonzero`, `array`, `panicking`, `simd` -- these modules are all unstable or not reexported in the standard library, so they're just remaining in the same status quo as before * `num::Float` - this extension trait for floats needs to be audited for functionality (much of that is happening in #27823) and may also want to be renamed to `FloatExt` or `F32Ext`/`F64Ext`. * Should the extension traits for primitives be stabilized in libcore? I believe other unstable pieces are not isolated to just libcore but also affect the standard library. cc #27701
2015-08-18Auto merge of #27823 - eefriedman:float-dep-core, r=alexcrichtonbors-279/+0
There wasn't any particular reason the functions needed to be there anyway, so just get rid of them, and adjust libstd to compensate. With this change, libcore depends on exactly two floating-point functions: fmod and fmodf. They are implicitly referenced because they are used to implement "%". Dependencies of libcore on Linux x86-x64 with this patch: ``` 0000000000000000 *UND* 0000000000000000 __powidf2 0000000000000000 *UND* 0000000000000000 __powisf2 0000000000000000 *UND* 0000000000000000 fmod 0000000000000000 *UND* 0000000000000000 fmodf 0000000000000000 *UND* 0000000000000000 memcmp 0000000000000000 *UND* 0000000000000000 memcpy 0000000000000000 *UND* 0000000000000000 memset 0000000000000000 *UND* 0000000000000000 rust_begin_unwind 0000000000000000 *UND* 0000000000000000 rust_eh_personality ```
2015-08-17core: Shuffle around float parsingAlex Crichton-100/+96
Stop using stability to hide the implementation details of ParseFloatError and instead move the error type into the `dec2flt` module. Also move the implementation blocks of `FromStr for f{32,64}` into `dec2flt` directly.
2015-08-17std: Clean up primitive integer modulesAlex Crichton-10/+30
All of the modules in the standard library were just straight reexports of those in libcore, so remove all the "macro modules" from the standard library and just reexport what's in core directly.
2015-08-17Remove dependencies on libm functions from libcore.Eli Friedman-279/+0
There wasn't any particular reason the functions needed to be there anyway, so just get rid of them, and adjust libstd to compensate. With this change, libcore depends on exactly two floating-point functions: fmod and fmodf. They are implicitly referenced because they are used to implement "%".
2015-08-15std: Add issues to all unstable featuresAlex Crichton-1/+2
2015-08-15core: Fill out issues for unstable featuresAlex Crichton-12/+24
2015-08-14Auto merge of #27641 - nikomatsakis:soundness-rfc-1214, r=nrcbors-2/+2
This PR implements the majority of RFC 1214. In particular, it implements: - the new outlives relation - comprehensive WF checking For the most part, new code receives warnings, not errors, though 3 regressions were found via a crater run. There are some deviations from RFC 1214. Most notably: - we still consider implied bounds from fn ret; this intersects other soundness issues that I intend to address in detail in a follow-up RFC. Fixing this without breaking a lot of code probably requires rewriting compare-method somewhat (which is probably a good thing). - object types do not check trait bounds for fear of encountering `Self`; this was left as an unresolved question in RFC 1214, but ultimately feels inconsistent. Both of those two issues are highlighted in the tracking issue, https://github.com/rust-lang/rust/issues/27579. #27579 also includes a testing matrix with new tests that I wrote -- these probably duplicate some existing tests, I tried to check but wasn't quite sure what to look for. I tried to be thorough in testing the WF relation, at least, but would welcome suggestions for missing tests. r? @nrc (or perhaps someone else?)
2015-08-13Auto merge of #27684 - alexcrichton:remove-deprecated, r=aturonbors-17/+0
This commit removes all unstable and deprecated functions in the standard library. A release was recently cut (1.3) which makes this a good time for some spring cleaning of the deprecated functions.
2015-08-12Fallout in libs -- misc missing bounds uncovered by WF checks.Niko Matsakis-2/+2
2015-08-12Remove all unstable deprecated functionalityAlex Crichton-17/+0
This commit removes all unstable and deprecated functions in the standard library. A release was recently cut (1.3) which makes this a good time for some spring cleaning of the deprecated functions.
2015-08-12Mention that the fast path is broken without SSE.Robin Kruppe-3/+11
2015-08-08Accurate decimal-to-float parsing routines.Robin Kruppe-15/+2420
This commit primarily adds implementations of the algorithms from William Clinger's paper "How to Read Floating Point Numbers Accurately". It also includes a lot of infrastructure necessary for those algorithms, and some unit tests. Since these algorithms reject a few (extreme) inputs that were previously accepted, this could be seen as a [breaking-change]
2015-08-08Add various methods to Bignum:Robin Kruppe-5/+141
- Exposing digits and individual bits - Counting the number of bits - Add small (digit-sized) values - Multiplication by power of 5 - Division with remainder All are necessary for decimal to floating point conversions. All but the most trivial ones come with tests.
2015-08-08Enlarge Bignum type from 1152 to 1280 bits.Robin Kruppe-6/+6
This is necessary for decimal-to-float code (in a later commit) to handle inputs such as 4.9406564584124654e-324 (the smallest subnormal f64). According to the benchmarks for flt2dec::dragon, this does not affect performance measurably. It probably uses slightly more stack space though.
2015-08-08Make core::num::dec2flt::strategy::grisu::Fp methods public.Robin Kruppe-3/+3
The intent is to allow decimal-to-float parsing to use Fp in its fast path. That code is added in a later commit.
2015-08-03syntax: Implement #![no_core]Alex Crichton-8/+11
This commit is an implementation of [RFC 1184][rfc] which tweaks the behavior of the `#![no_std]` attribute and adds a new `#![no_core]` attribute. The `#![no_std]` attribute now injects `extern crate core` at the top of the crate as well as the libcore prelude into all modules (in the same manner as the standard library's prelude). The `#![no_core]` attribute disables both std and core injection. [rfc]: https://github.com/rust-lang/rfcs/pull/1184
2015-07-28Replace occurences of illegal in user facing docsSimonas Kazlauskas-4/+4
2015-07-20std: Create separate docs for the primitivesBrian Anderson-12/+0
Having the primitive and module docs derived from the same source causes problems, primarily that they can't contain hyperlinks cross-referencing each other. This crates dedicated private modules in `std` to document the primitive types, then for all primitives that have a corresponding module, puts hyperlinks in moth the primitive docs and the module docs cross-linking each other. This should help clear up confusion when readers find themselves on the wrong page.
2015-07-19optimize from_str_radixarthurprs-11/+25
2015-07-13Auto merge of #26981 - wthrowe:div_docs, r=Gankrobors-4/+4
This resolves #26845. I'm not entirely satisfied with the placement of the rounding discussion in the docs for the `Div` and `Rem` traits, but I couldn't come up with anywhere better to put it. Suggestions are welcome. I didn't add any discussion of rounding to the `checked_div` (or rem) or `wrapping_div` documentation because those seem to make it pretty clear that they do the same thing as `Div`.
2015-07-11Correct and clarify integer division rounding docsWilliam Throwe-4/+4
2015-07-11Auto merge of #26878 - Esption:master, r=pnkfelixbors-1/+1
I noticed in docs, specifically http://doc.rust-lang.org/std/primitive.u8.html#method.is_power_of_two, that it was like this, and it was apparently in multiple places too. Didn't change any occurrences through the cross-depo things. There's a lot in /src/llvm/ for instance, but I'm not confident on how to go about sending fixes for those, so this is just what's in the base rust depo. r? @steveklabnik
2015-07-08'iff' for docs to 'if and only if'Esption-1/+1
2015-07-08Use wrapping_div call and correct the feature nameMathijs van de Nes-2/+2
2015-07-08Implement Div for Wrapping<T>Mathijs van de Nes-0/+10
Resolves #26867
2015-07-08Fixed some occurrences of 'if' being spelled 'iff'Esption-1/+1
2015-07-05Auto merge of #26473 - Eljay:missing_docs, r=alexcrichtonbors-0/+30
Fixes #24249 I've tagged all items that were missing docs to allow them to compile for now, the ones in core/num should probably be documented at least. This is also a breaking change for any crates using `#[deny(missing_docs)]` that have undocumented constants, not sure there is any way to avoid this without making it a separate lint?