Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Power of TWO

Status
Not open for further replies.

Electroenthusiast

Active Member
Hi everyone,
Okay, i know computer has no fingers, so it uses binary. That's ok. But i'm really not understanding this. This may be simple, but i think i'm thinking in a bit complicated way/wrong way. Please correct me if i'm wrong.
I'm getting confused with binary system... really!
So here's what i like to ask:

Consider this,

To represent 0,1,2,3... the computer(not just PC) uses this
00 = off, off = 0
01 = off, on = 1
10 = on, off = 2
11 = on, on = 3

so to represent 0,1,2,3 we require '2 bits' of memory, but people say the memory used is 2^2=4 bits.

Similarly,
000 = off,off,off = 0
001 = off,off,on = 1
010 = off,on,off = 2
011 = off,on,on = 3
100 = on,off,off = 4
101 = on,off,on = 5
110 = on,on,off = 6
111 = on,on,on = 7

Here we use 3 bits to represent, but they say memory used is 2^3 = 8 bits. It continues like this and we end up getting everything in powers of two.
I'm confused with this. I've searched enough on internet, but haven't understood why is it so, i mean memory stick, RAM, ROM, etc... = 128,256,....1GB,2GB,4GB,8GB....

My point here is: As above, it requires 2bits / 3 bits to represent the above numbers respectively. And so, the memory required is 2/3 bits IMO. But why/how exactly 'power of 2' comes into act?
 
Not sure where you are getting your info.

1 bits has 2 possible values 0 1 or 0 1 in decimal
2 bits has 4 possible values 00 01 10 11 or 0 1 2 3 in decimal

So if you have n bits you can use them to represent 2 to the nth values.

For example with 8 bits we get 2 to the 8th or 256 value, 0..255 in decimal.
 
I did not see anything at that site that contradicted what I said.

I am not quite sure what you mean in the quote above. What I can tell you is that because memory devices use binary for decoding that they tend to get twice as large each time you increase there size.

Ok, let me be more clear... Lets take an example
Consider an example: Assume '&' is represented in a system as '01011011'. Now, the character '&' is represented using a 8bit number. The space required to store '&' is eight bits. So the memory has to be '8 bits', but what actually is followed is that the memory is 2^8= 256 bits. How/Why 256 is used, when it actually used space/memory is just 8 bits? This is confusing me.
 
Last edited:
Ok, let me be more clear... Lets take an example
Consider an example: Assume '&' is represented in a system as '01011011'. Now, the character '&' is represented using a 8bit number. The space required to store '&' is eight bits. So the memory has to be '8 bits', but what actually is followed is that the memory is 2^8= 256 bits. How/Why 256 is used, when it actually used space/memory is just 8 bits? This is confusing me.

That's because it's eight bits - NOT 256 - an eight bit number can represent from 0 to 255 (in decimal).
 
Nigel, i didn't get you properly.
So consider '&' as 1011011 - 7 Bit representation. Is this possible? I hope you understood what i asked before.

Yes, that's then only seven bits - perfectly possible - but using seven bits only allows you 128 different characters, which is what proper internet email actually gives you.
 
I think you are confused by the equation itself........ 2^8 means 2 conditions ... 1 or 0.... represented in 8 bits..... 00000000 which is 1 byte or one location in memory.... this location can have the value of 0 - 255.


The power 2 comes from adding 1 single bit.... 255 + 1 more most significant bit will become 511. 1 more 1023...2047....4095.. etc.. always doubles (2^n)
I'm using 1 less than max as 0 - 255 is 256 as I'm sure you know.
 
Last edited:
Let me take a stab at this.

Let's introduce a new term "16 bit addressing"

What does that really mean? 16 bits can represent 0-65535 decimal locations. It can also represent -32767 to + 32768 relative addressing when we store this number in 2's complement notation. We could use signed binary e.g. the highest bit represents the sign. When that happens, we get to representations for Zero. 100000000000000 and 0000000000000000. That's not fun to deal with.

With 16 bits, you end up with (2^16)-1 # of distinct values.

A complication in all of this mess is what is the definition of 1K of say memory? It's more convenient to call a "K" of memory 1024 instead of 1000.

When we add an extra bit, we add 2^n more values. Thus 1111 which is 15, if we add an extra bit or 2^4 we add 16 decimal more values.

Just like our decimal representation, each bit has a decimal value. From right to left, you get 2^3; 2^2; 2^1 and 2^0 or 8 4 2 1 decimal.

There are two things that need to be considered:
1) # of bits
2) Representation

Common representation are "unsigned binary", "signed binary", 2's complement binary and grey code.

What is grey code: It's a form of representation where only one bit changes when you increment a number. This is very useful in positioning systems.

We can get wierder and say, we have a 0-127 number, but we represent it as 8 bits. The 8th bit is parity and it could be say ODD or EVEN. That bit is added to make the number of 1's even or odd. This is basically the ASCII character set and we have defined a representation.

One issue that could be casing the inability to play catch is counting from 0 rather than 1 and using it interchangeably.

In decimal we have something similar: 10^2; 10^1; 10^0; 10^-1

We could have decimals in binary too. 11.01 could be a binary number. 1*(2^1) + 1*(2^0)+ 0*(2^-1) and 1* (2^-2)

Instead we create a "floating point notation" which has a mantissa and an exponent. The exponent has to be signed too.

Base e also exists. e.g e^3; e^2; e^1 and e^0 where e is 2.1828.... This means that the base or Radix could be arbitrary. One computer system I worked with stored passwords in Base50. Thus 16 bits could hold 3 characters of a specific set. All upper/lower case + numbers, a . and one other character.
 
Last edited:
Let me take a stab at this.

Let's introduce a new term "16 bit addressing"

What does that really mean? 16 bits can represent 0-65535 decimal locations. It can also represent -32767 to + 32768 relative addressing when we store this number in 2's complement notation. We could use signed binary e.g. the highest bit represents the sign. When that happens, we get to representations for Zero. 100000000000000 and 0000000000000000. That's not fun to deal with.

Okay, lets leave out all the stuffs like signed, unsigned, 1's complement .... etc.,
Now, here's what i've been asking.
You took '16' bits. Now, to represent a character, we use 16 bits in a particular system, the memory it requires = 16 bits. Have you ever seen a memory that isn't a multiple of 2?
Assume that i want to buy a RAM/Memory Stick, i can get it in values like 128k, 256, 512....1G, 2G, 4G, 8, 16, 32... and so on. Why that multiplication of 2. Why wont you get something in between? like 136k etc.,
If you represent a character with 7 bits, then a memory of 7 is enough, but have you ever heard of memory in that odd number(which is not a power of 2)?

What i'm basically asking here is, How/Why Power of 2 comes into being?
 
I think I tried to address that:

1 add a bit 11 1>>3
11 add a bit 111 3>>7
111 add a bit 1111 7>>15
1111 add a bit 11111 15 >>31

...
11 11111111 111 11111111 1023 >> 2047 1K to 2K
111 11111111 1111 11111111 2047>> 4097 2K to 4K

Note that if you add 1 more bit which is the minimum you can add, the amount addressable doubles. You really add 1 more because 0 is a physical location.
 
I think I tried to address that:

1 add a bit 11 1>>3
11 add a bit 111 3>>7
111 add a bit 1111 7>>15
1111 add a bit 11111 15 >>31

...
11 11111111 111 11111111 1023 >> 2047 1K to 2K
111 11111111 1111 11111111 2047>> 4097 2K to 4K

Note that if you add 1 more bit which is the minimum you can add, the amount addressable doubles. You really add 1 more because 0 is a physical location.

Okay KeepItSimpleStupid,
So if the no. of bits is
1 then memory = 2^1
11 then memory = 2^2
111 then memory = 2^3
... and so on.

But one thing i really did not understand is: 'Why we need to take power of 2 ?'

1 = 1 bit;
0 = 1 bit

But when you ask for the memory present/occupied, we say it as 2^1 = 2. Why 2^1, can't we say it as 1 bit?
 
Last edited:
A bit is a binary digit having the value of 0 or 1 just like a decimal digit has the value of 0 thru 9.

Well 999 is 3 decimal digits which is 10^3 or 1000 locations. We used 10 instead of 2 because 10 is the base.

Memory has another modifier next to it. i.e 16 Kb or 16 Killo bits. We tend to drop the bits. Kb is killobits and KB is killobytes. Watch out for that.

Computer memory may also have a modifier too such as 8k x 8 or 8k x 16 or 8k x 32.
If it's parity memory, we generally don't count the parity bit.

Here is a datasheet for an old memory chip, a 6116: https://www.datasheets.org.uk/6116 RAM-datasheet.html Note it's totally spelled out as 2k x 8bits.

Note here: **broken link removed**

it starts getting wierder. It's number of modules x amount and then the modules have an orientation too such as 4 GB = 512 Mb x 64 bits. The computer has a 64 bit word, so that's the unit we need multiples of.
 
A bit is a binary digit having the value of 0 or 1 just like a decimal digit has the value of 0 thru 9.

Well 999 is 3 decimal digits which is 10^3 or 1000 locations. We used 10 instead of 2 because 10 is the base.

Representing '3' in binary is 11, which requires 2 bits and not 2^2 = 4. This is the point i have problem., Okay, locations - please brief up with this term in relation with memory. Why no. of location should be equal to power of 2.

Here is a datasheet for an old memory chip, a 6116: https://www.datasheets.org.uk/6116 RAM-datasheet.html Note it's totally spelled out as 2k x 8bits.

Note here: **broken link removed**

it starts getting weirder. It's number of modules x amount and then the modules have an orientation too such as 4 GB = 512 Mb x 64 bits. The computer has a 64 bit word, so that's the unit we need multiples of.
 
1 =1 bit ... 11 = 2 bit... 111 = 3 bit .. through to... 11111111 = 8 bit <- all require 1 memory location to be stored in memory.

You keep saying 2^2 = 4 this means 2 to power of 2.... This equals four 4 combinations... 00, 01, 10, 11 ... or 0, 1, 2, 3 .. agreed
now add a bit 2^3 = 8 again 2 to the power 3..... there are 8 combinations......Oh look the number of combinations has doubled...

wen you reach 9 bits you will need two memory bytes up untill you get to 16 bits.......

Next... Memory increases in size because of the physical address bus on the memory.... 64k memory needs 16 bits to address every location. A0 ---- A15.
128k only needs one more bit ..... A0 ----- A17... If you want to address 4gig you need 32 bits... 8gig only needs 1 more bit, 33 bits.
you cant get half a bit.... 32.5 bits.. 6 gig ( you could address only 6 in software... but why... Just address up to 33 bits) .
 
Last edited:
Next... Memory increases in size because of the physical address bus on the memory.... 64k memory needs 16 bits to address every location. A0 ---- A15.
128k only needs one more bit ..... A0 ----- A17... If you want to address 4gig you need 32 bits... 8gig only needs 1 more bit, 33 bits.
you cant get half a bit.... 32.5 bits.. 6 gig ( you could address only 6 in software... but why... Just address up to 33 bits) .

;) ... 64k memory needs 16 bits for addressing bits, i understood that. 64k = 65536 memory locations = 8 x 64Kb = 192Kb(for 3 bits)/ 512Kb(for 8 bits) of memory. Or am i wrong?
Okay, is it not possible to design a memory without this power of 2, i mean 60k of memory but 16 bit of addressing bits? Why hasn't anyone done that?
 
Last edited:
Okay, is it not possible to design a memory without this power of 2, i mean 60k of memory but 16 bit of addressing bits? Why hasn't anyone done that?

Why???? that means 16 bits = 64k... addressing 60k STILL needs 16 bits... That would be a waste of 4k.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top