From c0e8f6fbfc5b603f2bd407302012fdf44669c26d Mon Sep 17 00:00:00 2001 From: tiye Date: Fri, 31 May 2024 01:19:58 +0800 Subject: [PATCH] random updates; tag 0.1.1 --- .github/workflows/publish.yaml | 7 +++++-- .github/workflows/test.yaml | 7 +++++-- Cargo.toml | 2 +- src/primes.rs | 6 +++--- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index ff3c49c..c252073 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -9,11 +9,14 @@ jobs: name: Publish to cargo runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + + - uses: dtolnay/rust-toolchain@stable with: toolchain: stable + - uses: Swatinem/rust-cache@v2 + - run: cargo test - uses: katyo/publish-crates@v1 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4070f8a..dd71dbf 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -12,9 +12,12 @@ jobs: name: Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + + - uses: dtolnay/rust-toolchain@stable with: toolchain: stable + - uses: Swatinem/rust-cache@v2 + - run: cargo test diff --git a/Cargo.toml b/Cargo.toml index 614e311..602f4e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dual_balanced_ternary" -version = "0.1.0" +version = "0.1.1" edition = "2021" license = "MIT" description = "Dual Balanced Ternary Arithmetic" diff --git a/src/primes.rs b/src/primes.rs index 0a1ff91..df6c782 100644 --- a/src/primes.rs +++ b/src/primes.rs @@ -93,9 +93,9 @@ impl TryFrom for DualBalancedTernary { let left = fractional_part.floor(); if left == 0.0 { // nothing - } else if (left - 1.0).abs() < std::f64::EPSILON { + } else if (left - 1.0).abs() < f64::EPSILON { result = result.add_at(f_idx, Dbt3); - } else if (left - 2.0).abs() < std::f64::EPSILON { + } else if (left - 2.0).abs() < f64::EPSILON { result = result.add_at(f_idx + 1, Dbt3); result = result.add_at(f_idx, Dbt7); } else { @@ -240,7 +240,7 @@ impl TryFrom<&Vec> for DualBalancedTernary { continue; } // println!("reading: {} {}", idx, x); - if idx < (int_range + 1) as usize { + if idx < int_range + 1 { integral.push(DualBalancedTernaryDigit::try_from((x & 0b11110000) >> 4)?); integral.push(DualBalancedTernaryDigit::try_from(x & 0b00001111)?); } else {