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

Function float_pow

crates/vm/src/builtins/float.rs:157–168  ·  view source on GitHub ↗
(v1: f64, v2: f64, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

155}
156
157pub fn float_pow(v1: f64, v2: f64, vm: &VirtualMachine) -> PyResult {
158 if v1.is_zero() && v2.is_sign_negative() {
159 let msg = "zero to a negative power";
160 Err(vm.new_zero_division_error(msg.to_owned()))
161 } else if v1.is_sign_negative() && (v2.floor() - v2).abs() > f64::EPSILON {
162 let v1 = Complex64::new(v1, 0.);
163 let v2 = Complex64::new(v2, 0.);
164 Ok(v1.powc(v2).to_pyobject(vm))
165 } else {
166 Ok(v1.powf(v2).to_pyobject(vm))
167 }
168}
169
170impl Constructor for PyFloat {
171 type Args = OptionalArg<PyObjectRef>;

Callers 1

inner_powFunction · 0.85

Calls 6

newFunction · 0.85
absMethod · 0.80
ErrClass · 0.50
is_zeroMethod · 0.45
to_ownedMethod · 0.45
to_pyobjectMethod · 0.45

Tested by

no test coverage detected