Re: [PATCH v5 3/3] rust: math: add signed division and remainder helpers

From: Andreas Hindborg

Date: Mon Nov 02 2026 - 10:37:38 EST


"chenhan" <chenhan0017.work@xxxxxxxxx> writes:

> Delta's division and remainder implementations operate on integers and
> do not depend on time units. Move them into a math module to provide a
> common home for arithmetic helpers, with Delta as the initial user.
>
> Expose div64_s64() for an i64 dividend and divisor, and div_s64_rem()
> for an i64 dividend and an i32 divisor. The latter returns an i64 quotient
> and an i32 remainder, matching the results of the C helper without
> exposing its output pointer. Delta's rem_nanos() uses the remainder and
> converts it to i64. Both helpers retain Rust's signed operator semantics
> and unconditional panic checks, using the existing C helpers on 32-bit.
>
> Keep the Delta API and its panic conditions unchanged. Document the
> quotient and remainder semantics and link to the corresponding C header.
> This is separate from the preceding behavior fix so that introducing
> the math module is not required for a backport.
>
> Assisted-by: LLM
> Signed-off-by: chenhan <chenhan0017.work@xxxxxxxxx>

Please add a doctest with a few asserts that demonstrate the use.

Best regards,
Andreas Hindborg