MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / log

Function log

std/math/src/main/float.rs:55–67  ·  view source on GitHub ↗
(x: f64, rest: Args)

Source from the content-addressed store, hash-verified

53// Optional second positional `base`, matching `math.log(x[, base])`.
54#[plugin_fn]
55fn log(x: f64, rest: Args) -> Result<f64> {
56 if x <= 0.0 { return Err(dom()); }
57 let ln = libm::log(x);
58 match rest.len() {
59 0 => Ok(ln),
60 1 => {
61 let base = rest.get::<f64>(0).unwrap()?;
62 if base <= 0.0 { return Err(dom()); }
63 Ok(ln / libm::log(base))
64 }
65 _ => Err(Error::Type(String::from("log expected at most 2 arguments"))),
66 }
67}
68
69#[plugin_fn]
70fn log2(x: f64) -> Result<f64> { if x <= 0.0 { return Err(dom()); } Ok(libm::log2(x)) }

Callers

nothing calls this directly

Calls 2

domFunction · 0.70
lenMethod · 0.45

Tested by

no test coverage detected