How base conversion works
To convert between bases, the standard approach is to first convert the source number to base 10 by multiplying each digit by its positional power of the source base and summing, then repeatedly divide the decimal result by the target base and collect remainders.
For conversions between powers of two (such as binary to octal or binary to hex), digit grouping is a faster shortcut: group the binary digits into sets of three for octal or four for hex and translate each group directly.