File tree 3 files changed +11
-1
lines changed
3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -1765,7 +1765,11 @@ assert_eq!((-a).mod_euc(-b), 1);
1765
1765
pub fn mod_euc( self , rhs: Self ) -> Self {
1766
1766
let r = self % rhs;
1767
1767
if r < 0 {
1768
- r + rhs. abs( )
1768
+ if rhs < 0 {
1769
+ r - rhs
1770
+ } else {
1771
+ r + rhs
1772
+ }
1769
1773
} else {
1770
1774
r
1771
1775
}
Original file line number Diff line number Diff line change 16
16
#![ feature( core_private_diy_float) ]
17
17
#![ feature( dec2flt) ]
18
18
#![ feature( decode_utf8) ]
19
+ #![ feature( euclidean_division) ]
19
20
#![ feature( exact_size_is_empty) ]
20
21
#![ feature( fixed_size_array) ]
21
22
#![ feature( float_internals) ]
Original file line number Diff line number Diff line change @@ -30,6 +30,11 @@ mod tests {
30
30
num:: test_num( 10 as $T, 2 as $T) ;
31
31
}
32
32
33
+ #[ test]
34
+ fn test_mod_euc( ) {
35
+ assert!( ( -1 as $T) . mod_euc( MIN ) == MAX ) ;
36
+ }
37
+
33
38
#[ test]
34
39
pub fn test_abs( ) {
35
40
assert!( ( 1 as $T) . abs( ) == 1 as $T) ;
You can’t perform that action at this time.
0 commit comments