Given 8 random bits forming a byte, can you determine whether the byte represents an integer or a character? Why?
One thing is not clear here. question is asking about character or unsigned character also.
- if 8 random bits are there means it is representing an integer.
Because if we talk about a character which has 8 bits but 7th bit is signed bit so that basically it will have -128 to 127 valuse.
but integer have 4-byte size means 4*8 = 32 bits where 31st bit is signed bit and other bit use for value.
So, if we go for random bits forming a byte. then there is possibility that 7th bit of the byte is 1 and that means if we go for character statement will become wrong because a character has 8 bit but 7th bit is used for a signed bit.
But if we go for integer and 7th bit is 1 than that statement remains true. because in integer 31st bit is signed bit. 7th bit is 1 or 0 is not make sense regarding sign in integer.
Get Answers For Free
Most questions answered within 1 hours.