If someone ever googles this, it can be useful one day... I had a look at the binary representations of powers of ten again, and I could confirm a funny thing: Powers of then have zeroes at the end. That's no surprise. But the number of zeros is the same in decimal and in binary representation.
10^0=d1=b1 0 zeroes 10^1=d10=b1010 1 zero 10^2=d100=b1100100 2 zeros 10^3=d1000=b1111101000 3 zeros ... I have no mathematical proof, and I'm not the one to find it. But I have tried it up to 10^56, which might be enough for many technical uses. So, if you have some power of ten in binary, you just have to find the rightmost "1", and you know what power it is. Greets, Kiste > I think I'm tired... I'm writing > weird code. Believe me or not, but if you feed powers of ten > to this strange thing, it divides them by 10: > > > var bit testbit_0 at digit_divisor:0 > var bit testbit_1 at digit_divisor:1 > var bit testbit_2 at digit_divisor:2 > var bit testbit_3 at digit_divisor:3 > var bit testbit_4 at digit_divisor:4 > var bit testbit_5 at digit_divisor:5 > var bit testbit_6 at digit_divisor:6 > var bit testbit_7 at digit_divisor:7 > var bit testbit_8 at digit_divisor:8 > var bit testbit_9 at digit_divisor:9 > > if testbit_0 then > digit_divisor=0 > elsif testbit_1 then > digit_divisor=1 > elsif testbit_2 then > digit_divisor=10 > elsif testbit_3 then > digit_divisor=100 > elsif testbit_4 then > digit_divisor=1000 > elsif testbit_5 then > digit_divisor=10000 > elsif testbit_6 then > digit_divisor=100000 > elsif testbit_7 then > digit_divisor=1000000 > elsif testbit_8 then > digit_divisor=10000000 > elsif testbit_9 then > digit_divisor=100000000 > end if > -- You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
