@@ -363,6 +363,13 @@ pytime_double_to_denominator(double d, time_t *sec, long *numerator,
363363}
364364
365365
366+ /* Convert a number to a fraction representation.
367+ *
368+ * Set *ratio to a 2-tuple (numerator, denominator) and return 1 on success.
369+ * Return 0 if the number has neither the as_integer_ratio() method nor
370+ * the numerator and denominator attributes.
371+ * Return -1 on error.
372+ */
366373static int
367374maybe_as_integer_ratio (PyObject * number , PyObject * * ratio )
368375{
@@ -416,6 +423,7 @@ maybe_as_integer_ratio(PyObject *number, PyObject **ratio)
416423 return * ratio ? 1 : -1 ;
417424}
418425
426+ /* PyNumber_Divmod() that always returns a 2-tuple. */
419427static PyObject *
420428checked_divmod (PyObject * a , PyObject * b )
421429{
@@ -439,6 +447,8 @@ checked_divmod(PyObject *a, PyObject *b)
439447 return result ;
440448}
441449
450+ /* Calculate numerator / denominator rounded to integer using
451+ * the specified rounding mode. */
442452static PyObject *
443453divide_and_round (PyObject * numerator , PyObject * denominator , _PyTime_round_t round )
444454{
@@ -483,6 +493,8 @@ divide_and_round(PyObject *numerator, PyObject *denominator, _PyTime_round_t rou
483493 return result ;
484494}
485495
496+ /* Calculate scale * numerator / denominator rounded to integer using
497+ * the specified rounding mode. */
486498static PyObject *
487499multiply_divide_and_round (long scale , PyObject * numerator , PyObject * denominator ,
488500 _PyTime_round_t round )
0 commit comments