Wired up the OwnedLiterals to the math functions.

This commit is contained in:
Tom Alexander
2020-06-13 22:52:07 -04:00
parent fdd467298a
commit 431b34dac7
2 changed files with 64 additions and 10 deletions

View File

@@ -138,21 +138,21 @@ impl Rem<MathNumber> for MathNumber {
}
impl MathNumber {
fn math_abs(&self) -> Option<OwnedLiteral> {
pub fn math_abs(&self) -> Option<OwnedLiteral> {
match self {
MathNumber::Failure => None,
MathNumber::Integer(num) => num.abs().try_into().ok(),
MathNumber::Decimal(num) => Some(OwnedLiteral::LFloat(num.abs())),
}
}
fn math_floor(&self) -> Option<OwnedLiteral> {
pub fn math_floor(&self) -> Option<OwnedLiteral> {
match self {
MathNumber::Failure => None,
MathNumber::Integer(num) => (*num).try_into().ok(),
MathNumber::Decimal(num) => Some(OwnedLiteral::LFloat(num.floor())),
}
}
fn math_ceil(&self) -> Option<OwnedLiteral> {
pub fn math_ceil(&self) -> Option<OwnedLiteral> {
match self {
MathNumber::Failure => None,
MathNumber::Integer(num) => (*num).try_into().ok(),