You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 fnrem(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?
I think to be consistent with C, rust should keep the % behavior as it is, but explicitly define it as the 'remainder' operation (with documentation pointing out that it's the same as Cs mod, but mathematically correct named).
That means renaming Num::module() to Num::rem(), and defining the actual mod method in a way that doesn't easily get confused with rem.
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 ofint::rem()
simply uses the%
operator:Shouldn't
int::rem()
's behavior be different? Why would Rust have two names for the same action?ping @graydon
The text was updated successfully, but these errors were encountered: