| 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 { |