In-My-Opinion.org

»I see the number 255 often. Why?«







Is it me or is there some universal computer programming thing of 255 being the max number for alot of things? With the War 2 and War 3 AND SC map editors, alot of things could only goto 255 etc. I've encountered it else where too.

posted by hungarian kid
  

in-my-opinion.org -> Technology, Computers, Science, Internet -> Computers and Internet -> I see the number 255 often. Why?



It's the biggest number you can fit in a byte, which is the basic unit of storage in a computer. A Byte is made up of eight Bits - which can be either zero or 1

Here's a few numbers with binary equivalents...

0 = 00000000
1 = 00000001
2 = 00000010
3 = 00000011
4 = 00000100
...
7 = 00000111
8 = 00001000
9 = 00001001
...
15 = 00001111
16 = 00010000
...
31 = 00011111
32 = 00100000
...
63 = 00111111
64 = 01000000
...
127 = 01111111
128 = 10000000
...
255 = 11111111

So if the level number was stored in a byte, it couldn't go higher than 255 and would either reset to zero or freak out the machine.

This is why you get stuff like 256 colours, 16 bit, 1024 resolution and so on. Binary numbers (powers of 2) are all over the place.

Anyone who didn't know might think it was a conspiracy White laugh

posted by Marl64
  

digital architecture



as already said, it has something to do with digital architecture. A bit has 2 states. Larger units are made by combining several bits.
For instance, 8 bits mean 256 states (representing the values 0-255 or -127-128).
The first IBM-PC had a 8 bit architecture. Meaning that the smallest amount of data which could be loaded and processed were 8 bit.
That's also the reason why they expanded the ASCII charset from 7 to 8 bit.
Therefore most compilers and programming languages for IBM-PC also had 8 bit variables as the smallest data type available. Because they were the smallest available data type, they were very appealing to programmers. So they always used 8 bit char variables. Of course this also had an effect on the data formats which those programmers designed.

posted by anonymyus
  





Reply to topic






RegisterRegister
Log inLog in
The time now is 2 December 2008, 02:06
php B.B.