MCPcopy Index your code
hub / github.com/RustPython/RustPython / log10

Function log10

crates/stdlib/src/math.rs:150–166  ·  view source on GitHub ↗
(x: PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

148
149 #[pyfunction]
150 fn log10(x: PyObjectRef, vm: &VirtualMachine) -> PyResult<f64> {
151 // Handle BigInt specially for large values (only for actual int type, not float)
152 if let Some(i) = x.downcast_ref::<PyInt>() {
153 return pymath::math::log10_bigint(i.as_bigint()).map_err(|err| match err {
154 pymath::Error::EDOM => vm.new_value_error("expected a positive input"),
155 _ => pymath_exception(err, vm),
156 });
157 }
158 let val = x.try_float(vm)?.to_f64();
159 pymath::math::log10(val).map_err(|err| match err {
160 pymath::Error::EDOM => vm.new_value_error(format!(
161 "expected a positive input, got {}",
162 super::float_repr(val)
163 )),
164 _ => pymath_exception(err, vm),
165 })
166 }
167
168 #[pyfunction]
169 fn pow(x: ArgIntoFloat, y: ArgIntoFloat, vm: &VirtualMachine) -> PyResult<f64> {

Callers

nothing calls this directly

Calls 4

pymath_exceptionFunction · 0.85
as_bigintMethod · 0.80
to_f64Method · 0.80
try_floatMethod · 0.80

Tested by

no test coverage detected