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

Function inner_pow

crates/vm/src/builtins/int.rs:141–162  ·  view source on GitHub ↗
(int1: &BigInt, int2: &BigInt, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

139);
140
141fn inner_pow(int1: &BigInt, int2: &BigInt, vm: &VirtualMachine) -> PyResult {
142 if int2.is_negative() {
143 let v1 = try_to_float(int1, vm)?;
144 let v2 = try_to_float(int2, vm)?;
145 float::float_pow(v1, v2, vm)
146 } else {
147 let value = if let Some(v2) = int2.to_u64() {
148 return Ok(vm.ctx.new_int(Pow::pow(int1, v2)).into());
149 } else if int1.is_one() {
150 1
151 } else if int1.is_zero() {
152 0
153 } else if int1 == &BigInt::from(-1) {
154 if int2.is_odd() { -1 } else { 1 }
155 } else {
156 // missing feature: BigInt exp
157 // practically, exp over u64 is not possible to calculate anyway
158 return Ok(vm.ctx.not_implemented());
159 };
160 Ok(vm.ctx.new_int(value).into())
161 }
162}
163
164fn inner_mod(int1: &BigInt, int2: &BigInt, vm: &VirtualMachine) -> PyResult {
165 if int2.is_zero() {

Callers 1

int.rsFile · 0.70

Calls 6

try_to_floatFunction · 0.85
float_powFunction · 0.85
powFunction · 0.50
new_intMethod · 0.45
is_zeroMethod · 0.45
not_implementedMethod · 0.45

Tested by

no test coverage detected