about summary refs log tree commit diff
path: root/src/libstd/f64.rs
AgeCommit message (Collapse)AuthorLines
2018-12-17rename div_euc -> div_euclid, and mod_euc -> rem_euclidNicole Mazzuca-15/+15
logic is written up in https://github.com/rust-lang/rust/issues/49048 Also, update the documentation slightly
2018-12-15Fix a small mistake regarding NaNs in a deprecation messageTobias Bucher-1/+2
`max` on floats returns the other argument if one of them is NaN, which would be `0.0` in this case. This is unlike the C functions `fdim` and `fdimf` which return NaN if either of their arguments is NaN. https://doc.rust-lang.org/1.31.0/std/primitive.f32.html#method.max https://en.cppreference.com/w/c/numeric/math/fdim
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-1/+1
2018-10-24Fix doc for new copysign functionsRaph Levien-4/+4
Thanks to @LukasKalbertodt for catching this. Addresses a comment raised in #55169 after it was merged.
2018-10-18Add must_use on copysignRaph Levien-0/+1
Added a #[must_use] annotation on copysign, per review feedback.
2018-10-17Fix inconsistent documentationRaph Levien-3/+4
I improved the f32 version and made a copy-paste error for f64.
2018-10-17Add a `copysign` function to f32 and f64Raph Levien-0/+27
This patch adds a `copysign` function to the float primitive types. It is an exceptionally useful function for writing efficient numeric code, as it often avoids branches, is auto-vectorizable, and there are efficient intrinsics for most platforms. I think this might work as-is, as the relevant `copysign` intrinsic is already used internally for the implementation of `signum`. It's possible that an implementation might be needed in japaric/libm for portability across all platforms, in which case I'll do that also. Part of the work towards #55107
2018-06-26Clarify rational behind current implementation of `.mod_euc()`Fabian Kössel-0/+4
2018-06-26Document round-off error in `.mod_euc()`-method, see issue #50179Fabian Kössel-1/+6
2018-05-17Switch to 1.26 bootstrap compilerMark Simulacrum-11/+1
2018-05-13Add “Examples” section header in f32/f64 doc comments.Corey Farwell-0/+76
This is recommend by [RFC 0505] and as far as I know, the only primitive types without this heading. [RFC 0505]: https://github.com/rust-lang/rfcs/blob/c892139be692586e0846fbf934be6fceec17f329/text/0505-api-comment-conventions.md#using-markdown
2018-05-10Rollup merge of #50588 - ExpHP:i-can-see-my-house-from-here, r=frewsxcvAlex Crichton-2/+2
Move "See also" disambiguation links for primitive types to top Closes #50384. <details> <summary>Images</summary> ![rust-slice](https://user-images.githubusercontent.com/1411280/39843148-caa41c3e-53b7-11e8-8123-b57c25a4d9e0.png) ![rust-isize](https://user-images.githubusercontent.com/1411280/39843146-ca94b384-53b7-11e8-85f3-3f5e5d353a05.png) </details> r? @steveklabnik
2018-05-09move See also links to topMichael Lamparski-2/+2
2018-05-09Clarify in the docs that `mul_add` is not always faster.Corey Farwell-2/+4
Fixes https://github.com/rust-lang/rust/issues/49842. Other resources: - https://users.rust-lang.org/t/why-does-the-mul-add-method-produce-a-more-accurate-result-with-better-performance/1626 - https://en.wikipedia.org/wiki/Multiply%E2%80%93accumulate_operation
2018-04-21Move intrinsics-based float methods out of libcore into libstdSimon Sapin-3/+14
Affected methods are `abs`, `signum`, and `powi`. CC https://github.com/rust-lang/rust/issues/32110#issuecomment-379503183
2018-04-21Add some f32 and f64 inherent methods in libcoreSimon Sapin-282/+9
… previously in the unstable core::num::Float trait. Per https://github.com/rust-lang/rust/issues/32110#issuecomment-379503183, the `abs`, `signum`, and `powi` methods are *not* included for now since they rely on LLVM intrinsics and we haven’t determined yet whether those instrinsics lower to calls to libm functions on any platform.
2018-03-28Address nits and tidy errors.Fabian Zaiser-2/+2
2018-03-26Implement RFC #2169 (Euclidean division).Fabian Zaiser-0/+50
Tracking issue: #49048
2018-03-21Fixed clockwise/counter-clockwise in atan2 documentation in f32 and f64Maxwell Borden-4/+5
and included that it returns radians
2018-02-11typo: correct endianess to endianness (this also changes function names!)Matthias Krüger-1/+1
2018-01-24Auto merge of #46931 - clarcharr:float_bits_core, r=alexcrichtonbors-3/+2
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-09remove implementation detail from docTrevor Spiteri-2/+2
2018-01-08doc: show that `f32::log` and `f64::log` are not correctly roundedTrevor Spiteri-10/+9
2017-12-22Expose float from_bits and to_bits in libcore.Clar Charr-3/+2
2017-12-21Make core::f32/f64 docs match std.Clar Charr-1/+1
2017-11-24Auto merge of #46012 - Gankro:float-conv-transmute, r=sfacklerbors-28/+43
Make float::from_bits transmute See commit message for details. See also this discussion here: https://github.com/rust-lang/rust/issues/40470#issuecomment-343803381 (may require libs team discussion before merging)
2017-11-23Make float::from_bits transmute (and update the documentation to reflect this).Alexis Beingessner-28/+43
The current implementation/documentation was made to avoid sNaN because of potential safety issues implied by old/bad LLVM documentation. These issues aren't real, so we can just make the implementation transmute (as permitted by the existing documentation of this method). Also the documentation didn't actually match the behaviour: it said we may change sNaNs, but in fact we canonicalized *all* NaNs. Also an example in the documentation was wrong: it said we *always* change sNaNs, when the documentation was explicitly written to indicate it was implementation-defined. This makes to_bits and from_bits perfectly roundtrip cross-platform, except for one caveat: although the 2008 edition of IEEE-754 specifies how to interpet the signaling bit, earlier editions didn't. This lead to some platforms picking the opposite interpretation, so all signaling NaNs on x86/ARM are quiet on MIPS, and vice-versa. NaN-boxing is a fairly important optimization, while we don't even guarantee that float operations properly preserve signalingness. As such, this seems like the more natural strategy to take (as opposed to trying to mangle the signaling bit on a per-platform basis). This implementation is also, of course, faster.
2017-11-20Fix some docs summary nitsMarco A L Barbosa-2/+3
2017-11-08std: Move the `cmath` module into the `sys` moduleAlex Crichton-47/+2
This commit moves the `f32::cmath` and `f64::cmath` modules into the `sys` module. Note that these are not publicly exported modules, simply implementation details. These modules are already platform-specific with shims on MSVC and this is mostly just a reflection of that reality. This should also help cut down on `#[cfg]` traffic if platforms are brought on which don't directly support these functions.
2017-09-08Revert "Add clamp functions"Jacob Kiesel-20/+0
This reverts commit c589f867f89d4e6e48c6602aed8e878208d4822f.
2017-09-08Revert "Add NAN examples"Jacob Kiesel-1/+0
This reverts commit f74c5d2e18e50c24de2cc1192bf2088cdaa61916.
2017-09-08Revert "Fix f64 examples"Jacob Kiesel-4/+2
This reverts commit 576426a05a1a6cb33eece7082d7341b7c6bb5277.
2017-09-08Revert "Fix documentation and formatting."Jacob Kiesel-4/+1
This reverts commit 2e34ff767113c6a15c5862b0646ca9ad7ffd81b1.
2017-09-08Revert "Add panic unit tests"Jacob Kiesel-18/+0
This reverts commit b762283e57ff71f6763effb9cfc7fc0c7967b6b0.
2017-09-04Add panic unit testsJacob Kiesel-0/+18
2017-09-01Fix documentation and formatting.Jacob Kiesel-1/+4
2017-08-26Fix f64 examplesJacob Kiesel-2/+4
2017-08-26Add NAN examplesJacob Kiesel-0/+1
2017-08-26Add clamp functionsJacob Kiesel-0/+20
2017-07-18float_bits_conv made it into 1.20est31-2/+2
2017-07-06Stabilize float_bits_convest31-4/+2
2017-07-03Make sNaN removal code tolerate different sNaN encodingsest31-5/+8
IEEE 754-1985 specifies the encoding of NaN floating point numbers, but while it mentions that NaNs can be subdivided into signaling and quiet ones, it doesn't fix the encoding of signaling NaNs in binary formats. This led to different implementations (CPUs) having different encodings. IEEE 754-2008 finally specified the encoding of signaling NaNs but some architectures are compatible with it, while others aren't. Certain MIPS and PA-RISC CPUs have different encodings for signaling NaNs. In order to have the float <-> binary cast feature of the std library be portable to them, we don't mask any quiet NaNs like we did before (only being compliant to IEEE 754-2008 and nothing else), but instead we simply pass a known good NaN instead. Note that in the code removed there was a bug; the 64 bit mask for quiet NaNs should have been `0x0008000000000000` instead of the specified `0x0001000000000000`.
2017-06-28Auto merge of #42431 - nagisa:core-float-2, r=alexcrichtonbors-18/+8
Fix NaN handling in is_sign_negative/positive This would be my proposed fix for the #42425 provided we decide it is indeed a problem. Note this would technically be a breaking change to a stable API. We might want to consider deprecating these methods and adding new ones.
2017-06-22Fix NaN handling in is_sign_negative/positiveSimonas Kazlauskas-18/+8
See #42425
2017-06-16Auto merge of #42430 - nagisa:core-float, r=alexcrichtonbors-4/+2
Re-implement float min/max in rust This also adds the relevant implementations into libcore. See #42423
2017-06-14Re-implement float min/max in rustSimonas Kazlauskas-4/+2
See #42423
2017-06-13Ignore some failing test on wasm32-unknown-emscriptenMarco A L Barbosa-0/+3
See #42629 and #42630.
2017-04-20Remove float_extrasJosh Stone-179/+0
[unstable, deprecated since 1.11.0]
2017-04-18Allow us to remove masking in the futureest31-2/+2
2017-04-18Preserve sNaN payload when converting them to quiet NaNsest31-7/+10