kaede 0.1.2

Kaede adalah rust library untuk operasi matematika sederhana.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::MathError;

pub fn logaritma(x: f64, basis: f64) -> Result<f64, MathError> {
    if x <= 0.0 || basis <= 0.0 || basis == 1.0 {
        Err(MathError::TipeError("bilangan positif dan basis tidak sama dengan 1".to_string()))
    } else {
        Ok(x.log(basis))
    }
}

pub fn log2(x: f64) -> Result<f64, MathError> {
    logaritma(x, 2.0)
}

pub fn log10(x: f64) -> Result<f64, MathError> {
    logaritma(x, 10.0)
}