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

Function nextafter

crates/stdlib/src/math.rs:448–463  ·  view source on GitHub ↗
(arg: NextAfterArgs, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

446
447 #[pyfunction]
448 fn nextafter(arg: NextAfterArgs, vm: &VirtualMachine) -> PyResult<f64> {
449 let x = arg.x.into_float();
450 let y = arg.y.into_float();
451
452 let steps = match arg.steps.into_option() {
453 Some(steps) => {
454 let steps: i64 = steps.into_int_ref().try_to_primitive(vm)?;
455 if steps < 0 {
456 return Err(vm.new_value_error("steps must be a non-negative integer"));
457 }
458 Some(steps as u64)
459 }
460 None => None,
461 };
462 Ok(pymath::math::nextafter(x, y, steps))
463 }
464
465 #[pyfunction]
466 fn ulp(x: ArgIntoFloat) -> f64 {

Callers 2

test_countMethod · 0.90

Calls 6

into_floatMethod · 0.80
into_optionMethod · 0.80
try_to_primitiveMethod · 0.80
into_int_refMethod · 0.80
ErrClass · 0.50
SomeClass · 0.50

Tested by 2

test_countMethod · 0.72