rl_lang/interpreter/stdlib/math/log10.rs
1use crate::{
2 interpreter::{evaluator::Evaluator, values::Value},
3 utils::{errors::Error, span::Span},
4};
5
6pub fn std_log10(eval: &mut Evaluator, a: Value, span: Span) -> Result<Value, Error> {
7 match a {
8 Value::Integer(i) => Ok(Value::Float((i as f64).log10())),
9 Value::Float(f) => Ok(Value::Float(f.log10())),
10 other => Err(eval.err(
11 format!("log10() expects a number, got {}", other.type_name()),
12 span,
13 )),
14 }
15}