summaryrefslogtreecommitdiffstats
path: root/src/iter.rs
blob: f8aa6cb07a75aa6a41fbbc0e27b34d16543f7daa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
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)
}