Login

Welcome, Guest. Please login or register.

March 29, 2024, 02:29:03 am

Author Topic: Decimal Notation in Binary (The Interrelationship between Software and Hardware)  (Read 1719 times)  Share 

0 Members and 1 Guest are viewing this topic.

ghostmatrix

  • Fresh Poster
  • *
  • Posts: 2
  • I'm Batman
  • Respect: 0
Binary fractions are shown as negative powers of 2…

2^-1=0.5
2^-2=0.25
2^-3=0.125
2^-4=0.0625
And so forth…

When a decimal number is not an exact power of 2, you find powers of 2 that can be added together to make the number. This however is difficult, there is easy way to work that kinda **** out…

Eg 0.3125 in binary is 0.0101 (Base 2) Proof?

0.3125*2=0.625    0
0.625*2=1.25   1
0.25*2=0.5    0
0.5*2=1    1

What you do here is multiply the fraction by two then note if the result is >=1 and note if it is or not with a 1 or an 0, until it ends at 1. Sometimes it doesn't and continues forever but you will never be asked such a number in the HSC I don't believe.

Therefore 0.0101… = 0.3125

But there are no decimal points in binary… so what do we do?
Fixed or floating point!

Fixed is basic… Eg 15.625 would be

1111 1010 the first 4 bits are the integer part, the next for the fractional/decimal point part

This is limiting AF, so nothing really uses this… It doesn't just have to be over 8 bits, just the fact that the point is fixed causes the limitation… So what do we do? How about we move the decimal point around?

Floating Point!

3 parts (or bits, well not really but it's funny right?)
  • Sign Bit (A literal bit)
  • Exponent (8 Bits, A Byte)
  • Mantissa (23 bits, this actually contains the actual number, well minus a bit but get to that later)

Sign bit.
0 is positive, 1 is negative. Seriously, That’s all you need.

Exponent
The power of 2 of how many places you have to move the "decimal point" to the left (or right for negative powers really), then add 127 to make the exponent. Simple? Yes, but do the next part first though… But saying that you read this in order to understand what the hell is happening if you are given one…

Mantissa
This is the actual number part. You write the integer part of the number first and then the decimal part directly after, the exponent is what tells you where the "decimal point" is. Also the first bit of this number is dropped… Because you don't really need it (What is the first number of every binary number? 1, 10, 11, 100, 101…) IT'S 1!!!, so you can save a bit this way. Also this part 23 bits long… so get counting when you write then down.

So… In practice…
-18.125 is…

Sign:
1 (It's negative…)

Exponent:
Power is 4, so 4 bits to the left (OF THE MANTISSA) is where the decimal point is
127+4=131
131 in binary?
10000100

Mantissa:
18 is 10010 in binary
.125 is .001 So full number is
1010001 but drop the 1 to get
0010001 THEN you Add the 0's
00100010000000000000000

So… -18.125 in floating point 32 bit binary is… Split up for your viewing pleasure :P
1 10000100 00100010000000000000000
32 bits long just make sure of that.
Your mind appeals to me. It resembles my own mind except you happen to be insane.

BPunjabi

  • Forum Obsessive
  • ***
  • Posts: 262
  • So... Hows life?
  • Respect: 0
Nice Guide Man!!! It works perfectly

Check out Eddie Woo's youtube channel as he gives so much information of all technology subjects. With Software and Hardware binary he explains it in detail in a simple format. I use him for IPT as my teacher was not developed as much as the rest of our class ::)
Did HSC in 2016 and was first person to get 100. Aeronautical engineering for me now :P
  <-- CLICK ME