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

Function divmod

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

Source from the content-addressed store, hash-verified

89}
90
91pub fn divmod(v1: f64, v2: f64) -> Option<(f64, f64)> {
92 if v2 != 0.0 {
93 let mut m = v1 % v2;
94 let mut d = (v1 - m) / v2;
95 if v2.is_sign_negative() != m.is_sign_negative() {
96 m += v2;
97 d -= 1.0;
98 }
99 Some((d, m))
100 } else {
101 None
102 }
103}
104
105// nextafter algorithm based off of https://gitlab.com/bronsonbdevost/next_afterf
106#[allow(clippy::float_cmp)]

Callers 15

Int2APFunction · 0.50
_ord2ymdFunction · 0.50
_format_offsetFunction · 0.50
_divide_and_roundFunction · 0.50
__new__Method · 0.50
__str__Method · 0.50
__divmod__Method · 0.50
isocalendarMethod · 0.50
_getstateMethod · 0.50
__hash__Method · 0.50
_getstateMethod · 0.50
__add__Method · 0.50

Calls 1

SomeClass · 0.50

Tested by 15

testArithmeticMethod · 0.40
testLargeArithmeticMethod · 0.40
drive_oneMethod · 0.40
strtodFunction · 0.40
test_halfway_casesMethod · 0.40
test_countMethod · 0.40
test_findMethod · 0.40
test_rfindMethod · 0.40
test_divmodMethod · 0.40
test_strptimeMethod · 0.40
test_strptime_tzMethod · 0.40