MCPcopy Create free account
hub / github.com/numpy/numpy / extract_unit_64

Function extract_unit_64

numpy/core/src/multiarray/datetime.c:43–55  ·  view source on GitHub ↗

* Computes the python `ret, d = divmod(d, unit)`. * * Note that GCC is smart enough at -O2 to eliminate the `if(*d < 0)` branch * for subsequent calls to this command - it is able to deduce that `*d >= 0`. */

Source from the content-addressed store, hash-verified

41 * for subsequent calls to this command - it is able to deduce that `*d >= 0`.
42 */
43static inline
44npy_int64 extract_unit_64(npy_int64 *d, npy_int64 unit) {
45 assert(unit > 0);
46 npy_int64 div = *d / unit;
47 npy_int64 mod = *d % unit;
48 if (mod < 0) {
49 mod += unit;
50 div -= 1;
51 }
52 assert(mod >= 0);
53 *d = mod;
54 return div;
55}
56
57static inline
58npy_int32 extract_unit_32(npy_int32 *d, npy_int32 unit) {

Callers 3

days_to_yearsdaysFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected