The Student Room Group

Computer Science - Binary question (Normalising)

How do you find the greatest number you can store with a certain number of bits.
Example Question
Write the largest possible positive number that can be stored in this format (6 bits FOR MANTISSA AND 2 BITS FOR EXPONENT)
Please explain your method so I can generalise the rule to other questions :smile:
Thanks!

Scroll to see replies

Sorry you've not had any responses about this. :frown: Are you sure you've posted in the right place? :smile: Here's a link to our subject forum which should help get you more responses if you post there. :redface:

You can also find the Exam Thread list for A-levels here and GCSE here. :dumbells:


Just quoting in Puddles the Monkey so she can move the thread if needed :h:

Spoiler

Reply 2
Original post by Someboady
How do you find the greatest number you can store with a certain number of bits.
Example Question
Write the largest possible positive number that can be stored in this format (6 bits FOR MANTISSA AND 2 BITS FOR EXPONENT)
Please explain your method so I can generalise the rule to other questions :smile:
Thanks!


I'll try answer this, albeit not 100%
Ex;
4 bit = 4^2 (4to the power of2) = 16
In binary you start counting with the number 0, obviously written as 0000
That means in a 4 bit you can store the values 0-15

So you could do;
4^2 -1 = (4to the power of2) - 1
to find the highest number that can be stored in x-bit.

For your Q it is a 6 bit, not 4 bit like above;

6 bit = 6^2 (6to the power of2) = 36

6^2 -1 = (6to the power of2) - 1
to find the highest number that can be stored in x-bit.

6^2 -1 = 36 - 1 = 35

Therefore the highest number that can be stored in 6bit is 35.

Hope I'm right/have helped :'D


PlGLET
(edited 7 years ago)
Original post by Someboady
How do you find the greatest number you can store with a certain number of bits.
Example Question
Write the largest possible positive number that can be stored in this format (6 bits FOR MANTISSA AND 2 BITS FOR EXPONENT)
Please explain your method so I can generalise the rule to other questions :smile:
Thanks!

The left most bit of mantissa is negative, and the left most bit of the exponent is also negative. Therefore, you want to fill all of the other spots that are not negative. so you would have 01111 for the mantisaa, and 01 for the exponent. This is because the left most bit of the mantissa would be -16 and the left most bit of the exponent would be -2 (you don't wan't these values if you are going for the greatest positive number).
Reply 4
I'm guessing 35 :'p


PlGLET
Reply 5
Original post by PlGLET
I'm guessing 35 :'p

Edit* I'm most likely wrong! The only answers I can think of are 35 or 63 :'D

PlGLET





PlGLET
Reply 6
I got the 63 by adding 1,2,4,8,16, & 32

Most likely wrong with both answers :-/


PlGLET
Reply 7
I figured it out. First bit of both the exponent and mantissa must be zero because obvo we dont want negative because in both cases the number will get smaller. Because we want the numbers as big as possible everything else should be a one. yay.
Reply 8
Original post by Someboady
I figured it out. First bit of both the exponent and mantissa must be zero because obvo we dont want negative because in both cases the number will get smaller. Because we want the numbers as big as possible everything else should be a one. yay.


What's the answer? :-)


PlGLET
Reply 9
011111 01
Reply 10
Original post by Someboady
011111 01


I wasn't far off... ;-)
(I haven't started learning this yet, as you've probably gathered)


PlGLET
Reply 11
I've just searched binary normalisation & I've got some learning to do!
:-)


PlGLET
Reply 12
Original post by PlGLET
I wasn't far off... ;-)
(I haven't started learning this yet, as you've probably gathered)


PlGLET


Yep, are you doing A level Computer Science?
Reply 13
Original post by Someboady
Yep, are you doing A level Computer Science?


I'm about to start an OU Computing & IT degree! :-o The first section is for people of all abilities, then branches off into different sections. Just trying to learn as much as possible before I start!
I understand it now... I think! :'D

I know you've explained it, but I want to make sure I know it & ask Qs;

The tutorials I have just been looking at showed 8 bits, 5 in the mantissa & 3 in the exponent, but I understand the above (if 6 in the mantissa & 2 in the exponent).

So;
[ 0, 0, 0, 0, 0, 0 ] [ 0, 0 ]
[ -1, 1/2, 1/4, 1/8, 1/16, 1/32 ] [ 2, 1 ]

I now understand the first '0' or '1' dictates if positive or negative, in the highest value as you say, would be a positive (0), then the rest of them in the mantissa would be 1's to indicate they're being used to add up to make the highest value;

Therefore;
=[011111]
=(16+8+4+2+1)over32 (as it goes down to 1/32 in a 6 bit mantissa).
=(31/32)

Then the exponent;
[ 0, 0 ]
[ 2, 1 ]
As it can only move right once, that is the number I use? Then it is in column one; so it's 1^1 or 1.

So;
(31/32) x 1 (cross 1's out)
31/32 = 0.96875

0.96875 = 0.5(1/2) + 0.25(1/4) + 0.125(1/8) + 0.0625(1/16) + 0.03125(1/32)

Does this mean the highest value is 0.96875, or do I have to add the 1 before the decimal?

:-)



PlGLET
Reply 14
Original post by PlGLET
I'm about to start an OU Computing & IT degree! :-o The first section is for people of all abilities, then branches off into different sections. Just trying to learn as much as possible before I start!
I understand it now... I think! :'D

I know you've explained it, but I want to make sure I know it & ask Qs;

The tutorials I have just been looking at showed 8 bits, 5 in the mantissa & 3 in the exponent, but I understand the above (if 6 in the mantissa & 2 in the exponent).

So;
[ 0, 0, 0, 0, 0, 0 ] [ 0, 0 ]
[ -1, 1/2, 1/4, 1/8, 1/16, 1/32 ] [ 2, 1 ]

I now understand the first '0' or '1' dictates if positive or negative, in the highest value as you say, would be a positive (0), then the rest of them in the mantissa would be 1's to indicate they're being used to add up to make the highest value;

Therefore;
=[011111]
=(16+8+4+2+1)over32 (as it goes down to 1/32 in a 6 bit mantissa).
=(31/32)

Then the exponent;
[ 0, 0 ]
[ 2, 1 ]
As it can only move right once, that is the number I use? Then it is in column one; so it's 1^1 or 1.

So;
(31/32) x 1 (cross 1's out)
31/32 = 0.96875

0.96875 = 0.5(1/2) + 0.25(1/4) + 0.125(1/8) + 0.0625(1/16) + 0.03125(1/32)

Does this mean the highest value is 0.96875, or do I have to add the 1 before the decimal?

:-)



PlGLET


I don't quite follow what you did with the Mantissa "over 32"
I think you've kind of got it but your mantissa is dependent on your exponent.
The largest positive number for any number of bits in the mantissa/exponent will be when the Mantissa and Exponent start with Zero and all the other bits are 1's.

So;[ 0, 0, 0, 0, 0, 0 ] [ 0, 0 ][ -1, 1/2, 1/4, 1/8, 1/16, 1/32 ] [ 2, 1 ]



With regards to this, remember that both the exponent and mantissa are in two's complement form.
[ Mantissa is not known yet] [ -2, 1 ]


Therefore;
=[011111]
=(16+8+4+2+1)over32 (as it goes down to 1/32 in a 6 bit mantissa).
=(31/32)
Then the exponent;




We always start with calculating the exponent so that we can find our mantissa.
So FIRST the exponent:
We said it was 011111 01
In the column format you've given, your exponent is:
[-2,1]
[0, 1]
exponent = +1.

Now we figure out our mantissa:
[Unknown]
[0,1,1,1,1,1]
So our implied binary point is after the Most significant bit. (after the zero)
We move the implied binary point one place to the right as indicated by our exponent of +1.
so now we know the place values of our mantissa.
[-2 , 1 , (1/2),(1/4),(1/8,(1/16)][0 , 1, 1, 1, 1 , 1 ]So its:1+ 1/2 +1/4 +1/8+1/16 = 1.3975 If you wanted to increase the highest positive number, i.e. the range of values, increase the number of bits in the exponent
For a 5 bit mantissa and 3 bit exponent:
largest positive value is

01111 011
Which represents

exponent = 3,
mantissa is therefore.1/2 + 1 + 2 + 4 + 8 =15.5So thats a bit of floating point binary for you :smile: I think you've overcomplicated it, with a bit of practice floating point binary will come easily! :smile:
Reply 15
What is 011111 01 as a number?



PlGLET
Reply 16
[....0.....0......0......0......0........0.....]
[...-1...1/2...1/4...1/8...1/16...1/32...]

Therefore;
[...0...1...1...1...1...1...]
As it goes down to 1/32, doesn't that mean I do;
32/2 = 16
32/4 = 8
32/8 = 4
32/16 = 2
32/32 = 1 written like;

(16+8+4+2+1) = 31
32 32

? :-/


PlGLET
Reply 17
Original post by PlGLET
[....0.....0......0......0......0........0.....]
[...-1...1/2...1/4...1/8...1/16...1/32...]

Therefore;
[...0...1...1...1...1...1...]
As it goes down to 1/32, doesn't that mean I do;
32/2 = 16
32/4 = 8
32/8 = 4
32/16 = 2
32/32 = 1 written like;

(16+8+4+2+1) = 31/32
32

? :-/


PlGLET





PlGLET
Reply 18
1/2+1/4+1/8+1/16+1/32=0.96875=31/32


PlGLET
Reply 19
6 bit mantissa; 32/x (1/32)
5 bit mantissa; 16/x (1/16)
4 bit mantissa; 8/x (1/8)

? :-/


PlGLET

Quick Reply

Latest

Trending

Trending