如何找到一个二进制数非常之快? (O(1)最好)之快、二进制数

2023-09-10 23:35:44 作者:最凉不过人心

有没有很快速的方法来找到一个整数的二进制数?例如,给定一个数 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?

推荐答案

是位操作黑客你在找什么?