The following describes a function which I want to solve mathematically rather than resorting to binary bit manipulation is possible:
$y = f(x)$
- $x$ is an arbitrary integer equal to or greater than $zero$. $Zero$ can be omitted if that helps.
- The function $f(x)$ sets all binary bits of $x$ to 0 except the two most significant (high order) bits that are set. Example: $f(10101100)=10100000$ and $f(01111111)=01100000$.
- I already have the $base 2 log$ calculated for $x$.
Using this pre-calculated $log$ or some other method, can we calculate $y$ mathematically without resorting to bit manipulation?
I'm looking for an alternative since bit manipulation for arbitrarily large numbers can be quite inefficient depending on what software platform and language you use.
PS: I'm not even sure what keywords to tag this question with.