zlacker

[parent] [thread] 4 comments
1. gpdere+(OP)[view] [source] 2019-11-11 14:42:23
Once you compute your log2, computing log10 is just a single multiplication though, so, it is in fact as most as easy.
replies(1): >>Mauran+ha
2. Mauran+ha[view] [source] 2019-11-11 15:56:05
>>gpdere+(OP)
It's a single multiplication - with an irrational (transcendental, actually) number. That is most certainly not "easy" for a computer, and elsewhere in the comments you can see how much of a problem that actually poses.

Also, counting digits in base 2 is not the log2. The former gives you the latter but not the reverse. Finding the number of decimal digits in a number given in base 2 is not a simplification.

replies(1): >>gpdere+Hi
◧◩
3. gpdere+Hi[view] [source] [discussion] 2019-11-11 16:50:41
>>Mauran+ha
Oh, agree that for arbitrary large or non integer inputs it might not work. But elsethread jepler has shown a solution off Hacker's Delight which which simply multiplies the index of the most significant bit with a magic constant.
replies(2): >>Mauran+sK >>slavik+sM
◧◩◪
4. Mauran+sK[view] [source] [discussion] 2019-11-11 19:32:33
>>gpdere+Hi
> But elsethread jepler has shown a solution off Hacker's Delight which which simply multiplies the index of the most significant bit with a magic constant.

...and then checks for and corrects the potential off-by-one thus incurred.

◧◩◪
5. slavik+sM[view] [source] [discussion] 2019-11-11 19:46:47
>>gpdere+Hi
When N is fixed, all algorithms become O(1). That's why they appear the same.

If you do these calculations by hand, the complexity will be more obvious because each operation will be smaller.

[go to top]