Talk:Find first and last set bit of a long integer: Difference between revisions

→‎Assumption - host word size: Log_2 is easy and cheap (log_10, not)
m (→‎More Clarification "set bit": my understanding of someone else's understanding of their understanding of my understanding. -- ~~~~)
(→‎Assumption - host word size: Log_2 is easy and cheap (log_10, not))
Line 143:
: This kind of things happen to people who love to overload operators. What many fail to realize is that seemingly innocuous expressions <code>a & b == 1</code> could do a lot of harm if one insists on using overloaded operators to force a uniform appearance on tasks that are only superficially similar. --[[User:Ledrug|Ledrug]] 19:44, 9 December 2011 (UTC)
:: Ya, I was beginning to think about that. I personally like polymorphism in operators and functions as a first cut. But I also like to have the ability to step out and get deep into the weeds if something demands it. Problem is that a lot of people seem to be in one camp or the other exclusively. :( --[[User:Dgamey|Dgamey]] 23:12, 9 December 2011 (UTC)
::: Actually, efficient MP engines only keep enough words around to represent the largest <code>1</code> bit needed to represent the number (they also do special tricks to handle negative numbers); they also keep around a count of how many words they are using (well duh!). That means that finding the “largest bit” (assuming positive) is possible in constant time. I don't know whether anyone really bothers with it though; the binary logarithm is not an operation that's needed very often given that the storage size is already known. (Finding the decimal logarithm though, that's tremendously valuable and also horribly expensive.) –[[User:Dkf|Donal Fellows]] 10:18, 12 June 2012 (UTC)
Anonymous user