summary refs log tree commit diff
path: root/src/libstd/f32.rs
AgeCommit message (Collapse)AuthorLines
2019-11-29Format libstd with rustfmtDavid Tolnay-45/+37
This commit applies rustfmt with rust-lang/rust's default settings to files in src/libstd *that are not involved in any currently open PR* to minimize merge conflicts. THe list of files involved in open PRs was determined by querying GitHub's GraphQL API with this script: https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8 With the list of files from the script in outstanding_files, the relevant commands were: $ find src/libstd -name '*.rs' \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ rg libstd outstanding_files | xargs git checkout -- Repeating this process several months apart should get us coverage of most of the rest of libstd. To confirm no funny business: $ git checkout $THIS_COMMIT^ $ git show --pretty= --name-only $THIS_COMMIT \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ git diff $THIS_COMMIT # there should be no difference
2019-11-09Auto merge of #63871 - BatmanAoD:FloatFnMustUse, r=withoutboatsbors-4/+42
Add #[must_use] to all functions 'fn(float) -> float' These are pure functions. ```rust impl f32/f64 { fn floor(self) -> Self; fn ceil(self) -> Self; fn round(self) -> Self; fn trunc(self) -> Self; fn fract(self) -> Self; fn abs(self) -> Self; fn signum(self) -> Self; fn mul_add(self, a: Self, b: Self) -> Self; fn div_euclid(self, rhs: Self) -> Self; fn rem_euclid(self, rhs: Self) -> Self; fn powi(self, n: i32) -> Self; fn powf(self, n: Self) -> Self; fn sqrt(self) -> Self; fn exp(self) -> Self; fn exp2(self) -> Self; fn ln(self) -> Self; fn log(self, base: Self) -> Self; fn log2(self) -> Self; fn log10(self) -> Self; fn abs_sub(self, other: Self) -> Self; fn cbrt(self) -> Self; fn hypot(self, other: Self) -> Self; fn sin(self) -> Self; fn cos(self) -> Self; fn tan(self) -> Self; fn asin(self) -> Self; fn acos(self) -> Self; fn atan(self) -> Self; fn atan2(self, other: Self) -> Self; fn exp_m1(self) -> Self; fn ln_1p(self) -> Self; fn sinh(self) -> Self; fn cosh(self) -> Self; fn tanh(self) -> Self; fn asinh(self) -> Self; fn acosh(self) -> Self; fn atanh(self) -> Self; fn clamp(self, min: Self, max: Self) -> Self; } ``` Part of #48926
2019-09-05Restore 'must_use' for 'clamp'; fix warning for testsKyle Strand-5/+4
2019-08-28Let 'clamp' be invoked without using return value; used in testsKyle Strand-1/+2
2019-08-28Annotate functions taking extra argsKyle Strand-1/+11
2019-08-28Add reason for each 'must_use'Kyle Strand-29/+29
2019-08-27Rollup merge of #63698 - Phosphorus15:master, r=nagisaMazdak Farrokhzad-4/+6
Fixed floating point issue with asinh function This should fixes #63271 , in which `asinh(-0.0)` returns `0.0` instead of `-0.0`. according to @nagisa > > > IEEE-754 (2008), section 9.2.1: > > > For the functions expm1, exp2m1, exp10m1, logp1, log2p1, log10p1, sin, tan, sinPi, atanPi, asin, atan, sinh, tanh, asinh, and atanh, f(+0) is +0 and f(−0) is −0 with no exception. > > and > > > sinh(±∞) and asinh(±∞) are ±∞ with no exception. After ensuring that the function `asinh` is the only function affected (functions like `sin`, `sinh` are all based on `cmath` library or `llvm` intrinsics), and that `atanh` always gives the correct result. The only function to modify is `asinh`.
2019-08-24Add 'must_use' to all functions 'fn(float) -> float'Kyle Strand-0/+28
2019-08-22Make use of existing constants.Tomasz Różański-10/+9
f32::consts::PI / 2.0 -> f32::consts::FRAC_PI_2 f32::consts::PI / 4.0 -> f32::consts::FRAC_PI_4 f64::consts::PI / 2.0 -> f64::consts::FRAC_PI_2 f64::consts::PI / 4.0 -> f64::consts::FRAC_PI_4
2019-08-22Change code formatting for readability.Tomasz Różański-9/+9
2019-08-20Refined implementations of `asinh` and `acosh`Phosphorus15-6/+8
2019-08-20Used `copysign` to avoid unnecessary branches.Phosphorus15-9/+1
2019-08-19test cases for both `f32` and `f64` on asinh(-0.0)Phosphorus15-0/+1
2019-08-19Added negative cases for `asinh` according to IEEE-754.Phosphorus15-4/+11
2019-07-07Stablize Euclidean Modulo (feature euclidean_division)CrLF0710-4/+2
2019-06-08Use stable wrappersYuki Okushi-1/+1
2019-04-05Change `copytest` parameter name from `y` to `sign`Will Hakes-5/+5
2019-03-29Stablize {f32,f64}::copysign().CrLF0710-2/+1
2019-03-25Clarify `{Ord,f32,f64}::clamp` docs a littleTobias Bucher-6/+16
Explicitly call out when it returns NaN, adhere to the panic doc guidelines.
2019-03-20Fix formatting and add unit tests for panic casesJacob Kiesel-1/+19
2019-03-20Add NAN test to docsJacob Kiesel-0/+1
2019-03-19Rollup merge of #58812 - jonhoo:floor_v_trunc, r=alexcrichtonMazdak Farrokhzad-4/+8
Clarify distinction between floor() and trunc() `floor()` rounds towards `-INF`, `trunc()` rounds towards 0. This PR clarifies this in the examples.
2019-03-15Auto merge of #58710 - EdorianDark:master, r=sfacklerbors-0/+21
Add clamp for ranges. Implements #44095 Ready for merge
2019-03-09add feature clampDirk Leifeld-0/+1
2019-03-09Revert "Revert "Add clamp functions""Dirk Leifeld-0/+20
2019-02-28Clarify distinction between floor() and trunc()Jon Gjengset-4/+8
2019-02-28libstd => 2018Taiki Endo-8/+8
2018-12-25Remove licensesMark Rousskov-10/+0
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-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-1/+1
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/+28
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-274/+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/+51
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-02-01Use constant for 180/π in to_degreesvarkor-0/+1
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-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