Floor function to the base 2 I'm not a math guy, so I'm kinda confused about this.
I have a program that needs to calculate the floor base $2$ number of a float.

Let say a number $4$, that base $2$ floor would be $4$. Other examples :


$5 \to 4$ 
$6 \to 4$ 
$8 \to 8$ 
$12 \to 8$ 
$16 \to 16$
$0.5 \to 0.5$ 
$0.6 \to 0.5$ 
$0.13 \to 0.125$


How would I do this and what is the name of this problem?
Let the number whose base 2 floor you want to find be $N$. We want to find the greatest $k\in \mathbb{Z}$ such that $2^k \leq N$. Take the base 2 log of both sides to get $k \leq \log_2{N}$. Since we want the maximum value of $k$ that still fulfills this inequality and that is an integer, we pick $k = \lfloor \log_2{N} \rfloor$. Then you just need to compute $2^k$, which is the actual value of your base 2 floor of $N$.

EDIT: So simply put, your wanted base 2 floor function $f_2$ looks like this:

$$ f_2(N) = 2^{\lfloor \log_2{N} \rfloor} $$

And for a floor in base $b$ (using the above logic), $f_b$ would be

$$ f_b(N) = b^{\lfloor \log_b{N} \rfloor} $$
Practical insight Floor of base two is nothing but the floor of a binary number. Floor of base 10 gives floor of decimals .
let's see examples
$$ floor_{10} 15.3=15$$
In binary-
$ floor_2 110$(decimal equivalent 6)$=100$ (decimal equivalent 4) so to do this function first convert it into binary then take only the left most 1 and put the rest as 0's

For values like 0.625 it can be broken down to binary form which is 0.101 then $floor_2 0.101 = 0.1$ in binary converting to decimal form we get 0.5