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

Function mod_

crates/common/src/float_ops.rs:70–81  ·  view source on GitHub ↗
(v1: f64, v2: f64)

Source from the content-addressed store, hash-verified

68}
69
70pub fn mod_(v1: f64, v2: f64) -> Option<f64> {
71 if v2 != 0.0 {
72 let val = v1 % v2;
73 match (v1.signum() as i32, v2.signum() as i32) {
74 (1, 1) | (-1, -1) => Some(val),
75 _ if (v1 == 0.0) || (v1.abs() == v2.abs()) => Some(val.copysign(v2)),
76 _ => Some((val + v2).copysign(v2)),
77 }
78 } else {
79 None
80 }
81}
82
83pub fn floordiv(v1: f64, v2: f64) -> Option<f64> {
84 if v2 != 0.0 {

Callers

nothing calls this directly

Calls 2

absMethod · 0.80
SomeClass · 0.50

Tested by

no test coverage detected