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
Right now, the only comparison operation between BigInt types is PartialOrd<Rhs = Self>. There are times, however, that other comparisons are helpful, especially comparisons against primitive integer types. Most of these comparisons could be Ord in the case of BigInt, BigUint, and BigRational, though comparisons involving complex numbers could not be Ord. Even comparisons across differently-signed bigint types are trivial, simply adding an O(1) sign check before the vector-based comparing.
Admittedly, the primitive type comparison can be done already (e.g. x >= BigUint::from(8u64) or x < 16u64.into()), but this is inefficient in terms of time and memory.
Naturally, the reverse (primitive cmp bigint) would also be helpful, though thankfully implementing that will be trivial when the above implementation is made; it's the same source code with some text swapped around. I don't know much about macros, but this sounds like a job for macros.
The text was updated successfully, but these errors were encountered:
The inference issue is pretty nasty, because it even breaks code that would otherwise have nothing to do with bigints, just by the compiler seeing the additional trait implementations present at all. And I fully expect it would have the same result if we extended others like Ratio too.
Right now, the only comparison operation between BigInt types is
PartialOrd<Rhs = Self>
. There are times, however, that other comparisons are helpful, especially comparisons against primitive integer types. Most of these comparisons could beOrd
in the case ofBigInt
,BigUint
, andBigRational
, though comparisons involving complex numbers could not beOrd
. Even comparisons across differently-signed bigint types are trivial, simply adding an O(1) sign check before the vector-based comparing.Admittedly, the primitive type comparison can be done already (e.g.
x >= BigUint::from(8u64)
orx < 16u64.into()
), but this is inefficient in terms of time and memory.Naturally, the reverse (primitive cmp bigint) would also be helpful, though thankfully implementing that will be trivial when the above implementation is made; it's the same source code with some text swapped around. I don't know much about macros, but this sounds like a job for macros.
The text was updated successfully, but these errors were encountered: