Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write integer value "60" in 16bit binary, 32bit binary & 64bit binary

How to write integer value "60" in other binary formats?

8bit binary code of 60 = 111100

16bit binary code of 60 = ?

32bit binary code of 60 = ?

64bit binary code of 60 = ?

is it 111100000000 for 16 bit binary?

why does 8bit binary code contain 6bits instead of 8?

I googled for the answers but I'm not able to get these answers. Please provide answers as I'm still a beginner of this area.

like image 385
Yoshida-hakimoto Avatar asked Feb 23 '26 03:02

Yoshida-hakimoto


2 Answers

Imagine you're writing the decimal value 60. You can write it using 2 digits, 4 digits or 8 digits:

1. 60
2. 0060
3. 00000060

In our decimal notation, the most significant digits are to the left, so increasing the number of digits for representation, without changing the value, means just adding zeros to the left.

Now, in most binary representations, this would be the same. The decimal 60 needs only 6 bits to represent it, so an 8bit or 16bit representation would be the same, except for the left-padding of zeros:

1. 00111100
2. 00000000 00111100

Note: Some OSs, software, hardware or storage devices might have different Endianness - which means they might store 16bit values with the least significant byte first, then the most signficant byte. Binary notation is still MSB-on-the-left, as above, but reading the memory of such little-endian devices will show any 16bit chunk will be internally reversed:

1. 00111100 - 8bit - still the same.
2. 00111100 00000000 - 16bit, bytes are flipped.
like image 165
Avner Shahar-Kashtan Avatar answered Feb 25 '26 17:02

Avner Shahar-Kashtan


every number has its own binary number, that means that there is only one! on a 16/32/64 bit system 111100 - 60 would just look the same with many 0s added infront of the number (regulary not shown) so on 16 bit it would be 0000000000111100 32 bit - 0000000000000000000000000011110 and so on

like image 27
anon Avatar answered Feb 25 '26 17:02

anon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!