Skip to content

Partial float refactor #397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ jobs:
- uses: actions/checkout@v1
with:
submodules: true
- name: Install Rust
run: rustup update stable && rustup default stable && rustup component add rustfmt
- name: Install stable `rustfmt`
run: rustup set profile minimal && rustup default stable && rustup component add rustfmt
- run: cargo fmt -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
submodules: true
# Unlike rustfmt, stable clippy does not work on code with nightly features.
# This acquires the most recent nightly with a clippy component.
- name: Install nightly `clippy`
run: |
rustup set profile minimal && rustup default "nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/clippy)" && rustup component add clippy
- run: cargo clippy -- -D clippy::all
2 changes: 1 addition & 1 deletion crates/panic-handler/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Hack of a crate until rust-lang/rust#51647 is fixed
//! This is needed for tests on targets that require a `#[panic_handler]` function

#![feature(no_core)]
#![no_core]
Expand Down
5 changes: 2 additions & 3 deletions src/float/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,8 @@ where
a_significand <<= shift;
a_exponent -= shift;
}
} else
/* addition */
{
} else {
// addition
a_significand += b_significand;

// If the addition carried up, we need to right-shift the result and
Expand Down
21 changes: 9 additions & 12 deletions src/float/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,22 @@ fn cmp<F: Float>(a: F, b: F) -> Result {
// a and b as signed integers as we would with a fp_ting-point compare.
if a_srep & b_srep >= szero {
if a_srep < b_srep {
return Result::Less;
Result::Less
} else if a_srep == b_srep {
return Result::Equal;
Result::Equal
} else {
return Result::Greater;
Result::Greater
}
}
// Otherwise, both are negative, so we need to flip the sense of the
// comparison to get the correct result. (This assumes a twos- or ones-
// complement integer representation; if integers are represented in a
// sign-magnitude representation, then this flip is incorrect).
else {
if a_srep > b_srep {
return Result::Less;
} else if a_srep == b_srep {
return Result::Equal;
} else {
return Result::Greater;
}
} else if a_srep > b_srep {
Result::Less
} else if a_srep == b_srep {
Result::Equal
} else {
Result::Greater
}
}

Expand Down
Loading