diff options
| author | bors <bors@rust-lang.org> | 2019-11-27 12:16:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-11-27 12:16:52 +0000 |
| commit | 04e69e4f4234beb4f12cc76dcc53e2cc4247a9be (patch) | |
| tree | 148834cf05a0062cc851f578c636241d0bd87b30 /src/libcore/num/flt2dec/decoder.rs | |
| parent | 876a72a251e0d533f776fa9149b3e4daaeea3a61 (diff) | |
| parent | 166471e7f1f05fe272a4df99c20c1ffc0204a25f (diff) | |
| download | rust-04e69e4f4234beb4f12cc76dcc53e2cc4247a9be.tar.gz rust-04e69e4f4234beb4f12cc76dcc53e2cc4247a9be.zip | |
Auto merge of #66691 - dtolnay:fmt0, r=sfackler
Format libcore with rustfmt I am interested in whether we can begin cautious incremental progress on #66688 and assess along the way whether we can keep the disruption sufficiently small. This PR applies rustfmt with default settings to files in src/libcore *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: ```console $ find src/libcore -name '*.rs' | xargs rustfmt --edition=2018 $ rg libcore outstanding_files | xargs git checkout -- ``` Repeating this process several months apart should get us coverage of most of the rest of libcore.
Diffstat (limited to 'src/libcore/num/flt2dec/decoder.rs')
| -rw-r--r-- | src/libcore/num/flt2dec/decoder.rs | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/libcore/num/flt2dec/decoder.rs b/src/libcore/num/flt2dec/decoder.rs index ee0f18ba295..2b74effbe2e 100644 --- a/src/libcore/num/flt2dec/decoder.rs +++ b/src/libcore/num/flt2dec/decoder.rs @@ -1,8 +1,8 @@ //! Decodes a floating-point value into individual parts and error ranges. -use crate::{f32, f64}; -use crate::num::FpCategory; use crate::num::dec2flt::rawfp::RawFloat; +use crate::num::FpCategory; +use crate::{f32, f64}; /// Decoded unsigned finite value, such that: /// @@ -47,11 +47,15 @@ pub trait DecodableFloat: RawFloat + Copy { } impl DecodableFloat for f32 { - fn min_pos_norm_value() -> Self { f32::MIN_POSITIVE } + fn min_pos_norm_value() -> Self { + f32::MIN_POSITIVE + } } impl DecodableFloat for f64 { - fn min_pos_norm_value() -> Self { f64::MIN_POSITIVE } + fn min_pos_norm_value() -> Self { + f64::MIN_POSITIVE + } } /// Returns a sign (true when negative) and `FullDecoded` value @@ -67,20 +71,29 @@ pub fn decode<T: DecodableFloat>(v: T) -> (/*negative?*/ bool, FullDecoded) { // neighbors: (mant - 2, exp) -- (mant, exp) -- (mant + 2, exp) // Float::integer_decode always preserves the exponent, // so the mantissa is scaled for subnormals. - FullDecoded::Finite(Decoded { mant, minus: 1, plus: 1, - exp, inclusive: even }) + FullDecoded::Finite(Decoded { mant, minus: 1, plus: 1, exp, inclusive: even }) } FpCategory::Normal => { let minnorm = <T as DecodableFloat>::min_pos_norm_value().integer_decode(); if mant == minnorm.0 { // neighbors: (maxmant, exp - 1) -- (minnormmant, exp) -- (minnormmant + 1, exp) // where maxmant = minnormmant * 2 - 1 - FullDecoded::Finite(Decoded { mant: mant << 2, minus: 1, plus: 2, - exp: exp - 2, inclusive: even }) + FullDecoded::Finite(Decoded { + mant: mant << 2, + minus: 1, + plus: 2, + exp: exp - 2, + inclusive: even, + }) } else { // neighbors: (mant - 1, exp) -- (mant, exp) -- (mant + 1, exp) - FullDecoded::Finite(Decoded { mant: mant << 1, minus: 1, plus: 1, - exp: exp - 1, inclusive: even }) + FullDecoded::Finite(Decoded { + mant: mant << 1, + minus: 1, + plus: 1, + exp: exp - 1, + inclusive: even, + }) } } }; |
