+ Compare<Bool = Self::Bool>
+ ConvertFrom<Self>;
fn abs(self) -> Self;
+ fn copy_sign(self, sign: Self) -> Self {
+ crate::algorithms::base::copy_sign(self.ctx(), self, sign)
+ }
fn trunc(self) -> Self;
fn ceil(self) -> Self;
fn floor(self) -> Self;
let mask = self.ctx().make(Self::PrimFloat::MANTISSA_FIELD_MASK);
self.to_bits() & mask
}
+ fn is_sign_negative(self) -> Self::Bool {
+ let mask = self.ctx().make(Self::PrimFloat::SIGN_FIELD_MASK);
+ self.ctx()
+ .make::<Self::BitsType>(0.to())
+ .ne(self.to_bits() & mask)
+ }
+ fn is_sign_positive(self) -> Self::Bool {
+ let mask = self.ctx().make(Self::PrimFloat::SIGN_FIELD_MASK);
+ self.ctx()
+ .make::<Self::BitsType>(0.to())
+ .eq(self.to_bits() & mask)
+ }
+ fn extract_sign_field(self) -> Self::BitsType {
+ let shift = self.ctx().make(Self::PrimFloat::SIGN_FIELD_SHIFT);
+ self.to_bits() >> shift
+ }
+ fn from_fields(
+ sign_field: Self::BitsType,
+ exponent_field: Self::BitsType,
+ mantissa_field: Self::BitsType,
+ ) -> Self {
+ let sign_shift = sign_field.ctx().make(Self::PrimFloat::SIGN_FIELD_SHIFT);
+ let exponent_shift = sign_field.ctx().make(Self::PrimFloat::EXPONENT_FIELD_SHIFT);
+ Self::from_bits(
+ (sign_field << sign_shift) | (exponent_field << exponent_shift) | mantissa_field,
+ )
+ }
fn sub_exponent_bias(exponent_field: Self::BitsType) -> Self::SignedBitsType {
Self::SignedBitsType::cvt_from(exponent_field)
- exponent_field
}
}
-pub trait Bool: Make + BitOps {}
+pub trait Bool: Make<Prim = bool> + BitOps + Select<Self> {}
-pub trait Select<T>: Bool {
+pub trait Select<T> {
fn select(self, true_v: T, false_v: T) -> T;
}
pub trait Compare: Make {
- type Bool: Bool + Select<Self>;
+ type Bool: Bool + Select<Self> + Make<Context = Self::Context>;
fn eq(self, rhs: Self) -> Self::Bool;
fn ne(self, rhs: Self) -> Self::Bool;
fn lt(self, rhs: Self) -> Self::Bool;