//! F9 — Math monomers: MC_72–MC_79
//!
//! Transcendental and mathematical functions on f64.

/// MC_72 — SIN: sine.
pub fn sin(x: f64) -> f64 { x.sin() }

/// MC_73 — COS: cosine.
pub fn cos(x: f64) -> f64 { x.cos() }

/// MC_74 — TAN: tangent.
pub fn tan(x: f64) -> f64 { x.tan() }

/// MC_75 — EXP: e^x.
pub fn exp(x: f64) -> f64 { x.exp() }

/// MC_76 — LN: natural logarithm. Returns NEG_INFINITY for 0, NAN for negative.
pub fn ln(x: f64) -> f64 { x.ln() }

/// MC_77 — LOG2: base-2 logarithm.
pub fn log2(x: f64) -> f64 { x.log2() }

/// MC_78 — POW: x raised to y.
pub fn pow(x: f64, y: f64) -> f64 { x.powf(y) }

/// MC_79 — CEIL: ceiling.
pub fn ceil(x: f64) -> f64 { x.ceil() }

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn math_basic() {
        assert!((sin(0.0)).abs() < 1e-10);
        assert!((cos(0.0) - 1.0).abs() < 1e-10);
        assert!((tan(0.0)).abs() < 1e-10);
        assert!((exp(0.0) - 1.0).abs() < 1e-10);
        assert!((ln(1.0)).abs() < 1e-10);
        assert!((log2(8.0) - 3.0).abs() < 1e-10);
        assert!((pow(2.0, 10.0) - 1024.0).abs() < 1e-10);
        assert_eq!(ceil(2.3), 3.0);
    }
}
