I am reading this material to understand the basics of number system.
I am stuck at a point in that material where it writes the algorithm to convert a decimal number to binary number.
The heading of that part where I am stuck is Decimal to Base
The algorithm it mentions there is:
(The algorithm below I copied and pasted from there but it isn't displayed here properlymay be presented less than faithfully, please refer the link) it mentions there is:
(1) Let P = int(square root of V)
(2) Let v = int(V ÷ B power(P))
(v is the next digit to the right)
(3)Make V = V − v * B power(p)
(4)Repeat steps 1 through 3 until p = 0
- Let $p = \lfloor \sqrt{V} \rfloor$
- Let $v = \lfloor \dfrac V {B^p} \rfloor$
(v is the next digit to the right)- Make $V = V − v * B^p$
- Repeat steps 1 through 3 until $p = 0$
It is explaining by taking an example of converting decimal number 236 to binary.
I am not getting how it is calculating the 1st step, i.e. to get the value of p.
It writes that p = int(square root of V)
Now, square root of 236 = 15.36229149573721635154
As per point number 1, p = integer part of 15.36229149573721635154 So, I remove the decimal part and p then becomes 15. But the material there says it is 7.
I can't get what is happening here. I am stuck.