Skip to content

Remainder is not modulus, but int::rem() uses the mod operator. #4565

Closed
@wting

Description

@wting

It turns out that Rust's % behavior mimics C99 (adopting the sign of the dividend). However the modulus and remainder are not the same, but Rust's implementation of int::rem() simply uses the % operator:

#[inline(always)]
pub pure fn rem(x: T, y: T) -> T { x % y }

Shouldn't int::rem()'s behavior be different? Why would Rust have two names for the same action?

ping @graydon

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