Z
zephyrtronium
I'm looking for a portable way to get the maximum number of bits in a
register, preferably at run time. Is there an easier method than
getting a popcount of a negated 0? If not, do I need 0, 0L, or 0LL? My
current solution (using GCC 4.5.0) is __builtin_popcount(~0L) which
gives me 32 on my 32-bit machine, but will that work in every case?
It seems __builtin_popcount(~0LL) also returns 32. Would that then
work in 64-bit processors? What about others? What if the processor
instruction set doesn't contain a popcount instruction?
Sorry if none of this makes any sense; I probably should have gone to
sleep many hours ago.
register, preferably at run time. Is there an easier method than
getting a popcount of a negated 0? If not, do I need 0, 0L, or 0LL? My
current solution (using GCC 4.5.0) is __builtin_popcount(~0L) which
gives me 32 on my 32-bit machine, but will that work in every case?
It seems __builtin_popcount(~0LL) also returns 32. Would that then
work in 64-bit processors? What about others? What if the processor
instruction set doesn't contain a popcount instruction?
Sorry if none of this makes any sense; I probably should have gone to
sleep many hours ago.