Skip to content

Bug in Int::div_rem_uint #847

@erik-3milabs

Description

@erik-3milabs

The following code fails an internal expect:

let num = I256::from_be_hex("eed8f6c7a5b1a65031ebc9b7a93492e89f282d49e75d25607a5693b3d8ae2e87");
let denom = U128::from_be_hex("de157f812521c55eccf9a903b31e4a34").to_nz().unwrap();
let (q, r) = num.div_rem_uint(&denom);

The author of the div_rem_uint function (=me) incorrectly assumed that the remainder of an int/uint will always fit in an int.

Edit: Actually, I was correct about this, until we modified Uint::div_rem to accept numerators and denominators with different LIMBS-sizes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions