Great work @JaylisPlay.
Leading zeros aren’t required in binary and when you see them they’re being used to either;
- show how much storage the number is using
- have some encoding reason to be there
On the storage front - an 8-bits equals 1 byte, and 4-bits can be represented as a single digit of hexadecimal.
Therefore, it’s quite common to see binary broken down into 4-digit chunk. This also aids readability, since it’s much easier to parse 4-digits at a time.
For your example of 162 = 10100010
it’s already 8-digits, so there’s no need to add any leading zeros. However, you could add some spaces and write it as 1010 0010
If instead, you had 98 = 0110 0010
it may be beneficial to add that extra leading zero to show that it takes up 1 byte of space.
If you’re encoding the binary into something else then the leading zeros do become important, as they will hold some information even when they’re zero.
For instance, when you encode a 32-bit signed integer, the first digit represents the sign of the number (0 = positive and 1 = negative), so including all of the digits can become important.
As an example 162 would be 0 000 0000 1010 0010
and -162 would be 1 000 000 1010 0010
(note the extra gap between the first and second digit being added for additional readability)
I hope that helps to answer your question.