• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kaidokert / fixed-bigint-rs / 16187943584

10 Jul 2025 06:36AM UTC coverage: 93.455% (+9.0%) from 84.416%
16187943584

push

github

web-flow
Improve coverage (#47)

* Improve coverage

1328 of 1421 relevant lines covered (93.46%)

909.57 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.75
/src/fixeduint/num_integer_impl.rs
1
use super::{FixedUInt, MachineWord};
2

3
use num_traits::{One, PrimInt, Zero};
4

5
// Most code here from num_integer crate, unsigned implementation
6

7
impl<T: MachineWord, const N: usize> num_integer::Integer for FixedUInt<T, N> {
8
    fn div_floor(&self, other: &Self) -> Self {
16✔
9
        *self / *other
16✔
10
    }
16✔
11
    fn mod_floor(&self, other: &Self) -> Self {
16✔
12
        *self % *other
16✔
13
    }
16✔
14
    fn gcd(&self, other: &Self) -> Self {
39✔
15
        // Use Stein's algorithm
16
        let mut m = *self;
39✔
17
        let mut n = *other;
39✔
18
        let zero = Self::zero();
39✔
19
        if m == zero || n == zero {
39✔
20
            return m | n;
15✔
21
        }
24✔
22

23
        // find common factors of 2
24
        let shift = (m | n).trailing_zeros();
24✔
25

26
        // divide n and m by 2 until odd
27
        m = m >> m.trailing_zeros();
24✔
28
        n = n >> n.trailing_zeros();
24✔
29

30
        while m != n {
30✔
31
            if m > n {
6✔
32
                m -= n;
3✔
33
                m = m >> m.trailing_zeros();
3✔
34
            } else {
3✔
35
                n -= m;
3✔
36
                n = n >> n.trailing_zeros();
3✔
37
            }
3✔
38
        }
39
        m << shift
24✔
40
    }
39✔
41
    fn lcm(&self, other: &Self) -> Self {
21✔
42
        if self.is_zero() && other.is_zero() {
21✔
43
            return Self::zero();
3✔
44
        }
18✔
45
        let gcd = self.gcd(other);
18✔
46
        *self * (*other / gcd)
18✔
47
    }
21✔
48
    fn divides(&self, other: &Self) -> bool {
×
49
        self.is_multiple_of(other)
×
50
    }
×
51
    fn is_multiple_of(&self, other: &Self) -> bool {
21✔
52
        (*self) % other == Self::zero()
21✔
53
    }
21✔
54
    fn is_even(&self) -> bool {
24✔
55
        (*self) & Self::one() == Self::zero()
24✔
56
    }
24✔
57
    fn is_odd(&self) -> bool {
12✔
58
        !self.is_even()
12✔
59
    }
12✔
60
    fn div_rem(&self, other: &Self) -> (Self, Self) {
12✔
61
        self.div_rem(other)
12✔
62
    }
12✔
63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc