Gennaro Prota:
The algorithm calculates log2 correctly even for those numbers. The invariant of the core algorithm is that at the start of each recursion 1 <= x && x>>n < 1ul<<n.Vesa Karvonen:Gennaro Prota:Vesa, I really appreciate your attempt but your code assumes the required number to be a power of two (it just tries 32, 64, 128, etc.). What about 48 bits unsigned long?[...]If unsigned long has 48 bits, then an n of 32 would be chosen.And then you are not able to calculate log2 for numbers in the range [2**32, 2**48-1[ (at least).
Regards,
Vesa Karvonen
_________________________________________________________________
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
