What is 48??
Quite a weird way to start a post about something right?? Well let's say it has some relevance to the details further, so how would you answer it??
You would probably say that it is a number right??
Well you are absolutely right and let me tell you more. You are actually looking a base 10 representation of a number. Interesting??? Told you there was some relevance to the first question I asked.
So 48 in our case(base 10) can also be written as 4*101 + 8*100
Makes sense?? Please continue its very interesting, I promise...
So there are different representation systems present for the numeric values.
We have Decimal(Base 10), Binary(Base 2), Ternary(Base 3), Quaternary(Base 4), Octal(Base 8) Hexadecimal(Base 16) upto Segsageximal(Base 60) and many more...
Not to overburden all at once and to maintain the sanctity of the topic we are discussing we will touch upon 2 systems namely Base 10 i.e Decimal and Base 2 i.e Binary.
You can refer below link as well along with this post to get more understanding on this. Maybe refer both at the same time.
Binary to Decimal - Dealing with fractions
So generally humans deal with Base 10 system as part of daily communication, Computers on the other hand deal with Base 2 or Binary system to deal with the numbers whichever form they may come in (positive, negative and so on).
Binary system essentially mean that everything should be written in either 0 or 1. Computers are well programmed to understand the 0s and 1s and act accordingly..
Moving ahead.. we did mention before how 48 the sample number in our case is represented in decimal format.
Now the same in binary would be 110000
How did we come up with this?? Same way we came up with the decimal methodology.
Decimal : 48 : 4*101 + 8*100
Binary : 110000 : 1*25 + 1*24 + 0*23 + 0*22 + 0*21 + 0*20
This is how the computers understand or interpret the number 48.
Moving ahead as mentioned previously there are different aspects to the number 48. Generally we would say 48, we can also say it as +48 that it is a positive number 48. What about negative numbers you say???
We humans mention negative 48 as - 48 or -ve 48. Computers do it a little differently.
So there are Unsigned numbers and Signed numbers. Unsigned fall under the positive range while signed have number range fall under both the positive and negative spectrum.
For unsigned 8 bit value, 00110000 would mean 48
However for a signed 8 bit 00110000 would mean +48 and 10110000 would mean -48. Notice a slight change which happened here... The right most bit or the Most Significant Bit as it is called is the SIGN bit which indicates whether the number is positive(0) or negative(1).
So for unsigned, the whole of 8 bits represent the magnitude or the value of the number and for signed only 7 bits would represent value and the MSB or the Most Significant Bit would represent the sign.
We discussed about the natural numbers, however we still need to hover over the subject of the real numbers where the possibilities of creating a number between 2 natural numbers is kind of infinite..
For example between 1 and 2, we can have 1.1, 1.2 as well as 1.001, 1.002 and so on..
Like we split the bits for representing the sign of the integer.. we would have 3 divisions here namely SIGN, EXPONENT, MANTISSA.
Before we go ahead, let's also understand the concept of scientific notation for numbers..
For say a number 48566, the scientific representation for the same would be 4.8566 * 104.
For 0.45737, we would have 4.5737 * 10-1
Now this is for base 10 representation..
Similarly we have base 2 representation as well..
So reverting back to the concept of sign, mantissa and exponent. To have a standard when dealing with storing the floating point number, somewhat 30 years ago at the time of this writing, came up a standard IEEE 754 which essentially directed on how to deal with floating numbers with half, single and double precision. All computers kind of conform to this standard whenever dealing with the floating point numbers
According to the standard, there will be
SIGN bit which will indicate whether the number will be positive(0) or negative( 1),
EXPONENT which will have information for the number in terms of power (in this case power of 2), helpful in representing very large or very small numbers. There is some bias added here which is different for both single and double precision. We will cover that later.
MANTISSA which will have the number after the decimal point in binary format.
Single Precision (32 bits) is represented as
Sign Bit (1 bit) | Exponent (8 bits) | Mantissa (23 bits) |
Double precision (64 bits) can be done as
Sign Bit (1 bit) | Exponent (11 bits) | Mantissa (52 bits) |
Single precision numbers comes with a bias of 127 while double precision has a bias of 1023. The makers of the standard chose this to ensure proper handling of negative exponents i.e to handle -127 to 127 in case of single precision and similarly in case of other precision.
Well that's something about computers speaking in 0s and 1s. We will try to add as much info as possible to add more clarity..
Until next time.. remember the geek talks!!
Powered by Froala Editor