blob: f8aa6cb07a75aa6a41fbbc0e27b34d16543f7daa (
plain) (
tree)
|
|
use num::BigInt;
pub fn next(v: &BigInt) -> BigInt
{
/*let t: BigUint = v | (v - 1);
(t + 1) | (((!t & -!t) - 1) >> (v.trailing_zeros() + 1))*/
let t: BigInt = (v | (v - 1u32)) + 1u32;
&t | ((((&t & -&t) / (v & -v)) >> 1) - 1u32)
}
|