#[derive(PartialEq, Clone, Debug)]
pub enum Sign {
Positive,
Negative,
}
impl Default for Sign {
fn default() -> Self {
Sign::Positive
}
}
impl Sign {
pub(crate) fn neg(&self) -> Sign {
match self {
Sign::Positive => Sign::Negative,
Sign::Negative => Sign::Positive,
}
}
pub(crate) fn mul(&self, other: &Sign) -> Sign {
match (self, other) {
(&Sign::Positive, &Sign::Negative) => Sign::Negative,
(&Sign::Negative, &Sign::Positive) => Sign::Negative,
_ => Sign::Positive,
}
}
pub(crate) fn _pow(&self, y: u64) -> Sign {
if self == &Sign::Negative && y % 2 == 1 {
Sign::Negative
} else {
Sign::Positive
}
}
pub fn ffi(&self) -> bool{
match self{
Sign::Negative => true,
Sign::Positive => false,
}
}
pub fn from_ffi(x: bool) -> Self{
match x{
true => Sign::Negative,
false => Sign::Positive,
}
}
}