Max number 255.. Why? why not 300, 200, 99????

CuriousAndy

Banned
May 28, 2001
1,563
0
0
I was playing StarCraft and noticed upgrades are limited to 255 times (using intensive SC map editor).. and Maximum number characters in AT sig is 255 as well...

Why is this 255 so common? does it have to do with computers using binary numbers or something? help me out

~andy
 

CuriousAndy

Banned
May 28, 2001
1,563
0
0
well why? and why u guys up so early on Saturday morning posting on ATOT?

I'm waiting for a phone call to goto Six Flags.. (New England one)

:D

Anyways.. the question still stands.. any answer?

~andy
 

CuriousAndy

Banned
May 28, 2001
1,563
0
0


<< 2^8 = 256 >>



Ok, I get that.. that computers deal with binary numbers..

but how does this practically affect the games and everything? ex) why is AT signature is limited to 255 characters? they can't afford more memory or somehting?

help this newbie out..

~andy
 

geno

Lifer
Dec 26, 1999
25,074
4
0
like rufruf said, 2^8 is 256

and I'm up because I'm at work ;)

edit - from what I understand, it's just easier to integrate into the program - can anyone here more versed at this sort of thing that can explain better??
 

Double Trouble

Elite Member
Oct 9, 1999
9,270
103
106
Yep, it's binary numbers. 2^1=2 2^2=4 2^3=8 2^4=16 2^5=32 etc 2^8=256. Since we use a system where 1 byte is composed of 8 bits, 2^8 comes up a lot in computer stuff. IP addresses are another example... each block of numbers in an IP address can be between 1 and 255.
 

CuriousAndy

Banned
May 28, 2001
1,563
0
0


<< edit - from what I understand, it's just easier to integrate into the program - can anyone here more versed at this sort of thing that can explain better?? >>



Yes.. could someone tell me how this affects in reality of practical applications and so on?

we already got that 2^8 = 255 part.. now gimme the 'get real' reason

~andy
 

iamfried

Senior member
Jan 28, 2001
445
0
0
The reason 'they' cut it off at 256 is 'they' think that this should be long enough for what you are doing with that input.
It also has to do with how big a byte is--8 bits.(like what tagej said) So if you wanted to go to a bigger number you would need to use 2 bytes of data. It all has to do with memory usage and trying to keep down program size and resources required to run that program.
So if you were writing a program and asked the user a question that had a yes/no answer, you wouldn't want to use a variable that took up 2 bytes when you could do what you wanted with 1 bit. (ie. boolean)
Some things go above 256 but that is because the programmer felt you might need more than 2^8 accuracy...
 

Noriaki

Lifer
Jun 3, 2000
13,640
1
71
For starcraft it's probably because 0-255 is one byte.
It's very easy to just assign everything one byte.

If they gave it two bytes (16bits) that would be 65535. Probably more than they want to allow you to have.

And if you try to do partial bytes...like 9 bits or 10 needed to store 500 or 1000 (512 and 1024 to be exact), then you start wasting space in the second bit, and need added complexity to get it because you have to do bit shifts and what not.

You can get around the wasted space by say assigned 10 bits for your upgrade level, and use the other 6 for something else, but then you have slide bits around to get at them and you just get undeeded complexity.

So it's simpler if you keep everything rounded to an even byte, and as I said they probably decided that 2 bytes was more than they wanted to allow, so they cut it off at one byte, thus 255 max.

As for the forum sig, I don't really know.
They probably decided that 250 would be enough, and just decided to make it 255 to be geeky ;)

There's no real programming reason I can think of to store it like that.
 

riddelrp

Senior member
May 19, 2001
554
0
0
I am sure they are using mySQL or MS SQL to serve this site. I am not knowledgable of these progs. However, I do know MS Access which is what I serve my personal site with. In MS access there are &quot;text fields&quot; and &quot;memo fields.&quot; A text field may only contain 255 characters, but a memo can hold infinite.

A memo field takes more space and is buggy. For instance when you make the call to the database from the web site the record set can only be used once. So if you pull memo field &quot;memo&quot; from a table named &quot;example&quot; to a record set rsEXAMPLE, then you retrieve the contents of &quot;memo&quot; using rsEXAMPLE(&quot;memo&quot;). If this occurs more then once in a page or any included pages then you get an error and NONE of the page will load. If it is only there once, but in a loop you still get an error. A simple work around is to make a variable equal it:

tempVAR = rsEXAMPLE(&quot;memo&quot;)

this sucks because it costs an extra line of code and another variable. Plus in the SQL statement where you call the database &quot;Select xxx, xxx, memo from EXAMPLE&quot; the memo field must be last or you get an error.

All these little annoying factors plus as already said about not wanting to use 2 bytes is why to limit to 255. I would rather deal with a text field then a memo field any day of the week.

I drive my site off a template page called &quot;default.asp&quot; then I send it a query string. So for instance my hobbies site would be /?hobbies. Since I set &quot;default.asp&quot; as the default site you don't have to type it in. Then I use the query string to grab the &quot;hobbies&quot; row from my sites DB. It grabs 6 different fields for each page then loads them into the template with the page &quot;inspecific&quot; stuff staying the same. The left side menu, main body, and right side boxes are memo fields. The status of the site logo, the header, &amp; the <title> tag are text fields.

-Ryan
 

Czar

Lifer
Oct 9, 1999
28,510
0
0
Think they are using Oracle or some big shot database program, not MySQL or MSSQL.
 

charrison

Lifer
Oct 13, 1999
17,033
1
81
czar,

Last time I checked, MS Sql is a big shot db. Ms Sql owns the TPC benchmarks on both performance and cost. And the Forums are using MS Sql. Varchar fields can be up to 8000 bytes longs and blobs(or Image) can be up to 2gig long.

Often limits are set because they think that the space allocated will more than enough storage thna what is actually required.