from_str_{binary,octal,hex} now rounds ties to even

This commit is contained in:
Trevor Spiteri 2019-08-17 21:45:32 +02:00
parent 1ba116110c
commit b15a1e8ef0
2 changed files with 333 additions and 294 deletions

File diff suppressed because it is too large Load Diff

View File

@ -42,6 +42,7 @@ where
const ZERO: Self;
fn is_negative(self) -> bool;
fn is_odd(self) -> bool;
fn checked_add(self, val: Self) -> Option<Self>;
fn checked_mul(self, val: Self) -> Option<Self>;
fn overflowing_add(self, val: Self) -> (Self, bool);
@ -114,6 +115,11 @@ macro_rules! sealed_int {
false
}
#[inline]
fn is_odd(self) -> bool {
self & 1 != 0
}
#[inline]
fn neg_abs(self) -> (bool, Self::Unsigned) {
(false, self)
@ -177,6 +183,11 @@ macro_rules! sealed_int {
self < 0
}
#[inline]
fn is_odd(self) -> bool {
self & 1 != 0
}
#[inline]
fn neg_abs(self) -> (bool, Self::Unsigned) {
if self < 0 {