如何找到一个二进制数非常之快? (O(1)最好) [英] How to find a binary logarithm very fast? (O(1) at best)
问题描述
有没有很快速的方法来找到一个整数的二进制数?例如,给定一个数 X = 52656145834278593348959013841835216159447547700274555627155488768这种算法必须找到Y =日志(X,2),它是215 x为总是2的幂。
Is there any very fast method to find a binary logarithm of an integer number? For example, given a number x=52656145834278593348959013841835216159447547700274555627155488768 such algorithm must find y=log(x,2) which is 215. x is always a power of 2.
这个问题似乎很简单。所有所需要的是找到最显著1位的位置。有一种公知的方法FloorLog,但它不是非常快特别是对于很长的多字的整数。
The problem seems to be really simple. All what is required is to find the position of the most significant 1 bit. There is a well-known method FloorLog, but it is not very fast especially for the very long multi-words integers.
什么是最快的方法是什么?
What is the fastest method?
推荐答案
是位操作黑客你在找什么?
这篇关于如何找到一个二进制数非常之快? (O(1)最好)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!