# representing number

This topic is 5198 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hi I've a strange problem (not a school task). How can I reprenesnt a number eg.13278 as the shortest possible string. If n is the number of possibilities for each character I guess I would need to create a base n number system. Am I correct? I can't remember much high school math.... cheers

##### Share on other sites
For an ASCII string, you have an upper limit of base 256, as each character can represent a digit 0-255. Don't expect this string to be human readable. The number of human readable characters is somewhere around 150 I am guessing.

This is somewhat of a unique question. For what purpose do you need to store these numbers?

##### Share on other sites
Thanks, It was just something I was wondering...

##### Share on other sites
Yes, you would create a base N number system. The larger the value of N, the less digits the number will have. The number of digits in the value x in base N is floor( logN x ) + 1.

##### Share on other sites
To represent 13278 you'd only need 2 8-bit characters (2^16 = 65536), this is also how a normal binary integer representation works.
However, not that not all of these ASCII characters can be used "safely". So for pratical purposes most text encodings of binary data (such as uuencode) limit themselves to using at most 6-bits per character (64 safe characters).

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 11
• 15
• 21
• 26
• 11