Add an abs function to the Float trait
There is no in-crate use for this yet, but we will make use of it in `libm`.
This commit is contained in:
parent
2f7fafd182
commit
394fb9f2bc
1 changed files with 5 additions and 0 deletions
|
|
@ -98,6 +98,11 @@ pub(crate) trait Float:
|
|||
/// Constructs a `Self` from its parts. Inputs are treated as bits and shifted into position.
|
||||
fn from_parts(negative: bool, exponent: Self::Int, significand: Self::Int) -> Self;
|
||||
|
||||
fn abs(self) -> Self {
|
||||
let abs_mask = !Self::SIGN_MASK ;
|
||||
Self::from_bits(self.to_bits() & abs_mask)
|
||||
}
|
||||
|
||||
/// Returns (normalized exponent, normalized significand)
|
||||
fn normalize(significand: Self::Int) -> (i32, Self::Int);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue