Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many characters can you store with 1 byte?

1 byte = 8 bits  

So, does this mean 1 byte can only hold one character? E.g.:

"16" uses 2 bytes , "9" uses 1 byte , "a" uses 1 byte, "b" uses 1 byte  

and if tiny int has range of 0-255, does this mean it can be stored with 255 char?

what is storage of

1. tiny int (1) 2. tiny int (2)  

what will be the range 0-10

like image 895
Abhi Adr Avatar asked Jan 23 '14 06:01

Abhi Adr


People also ask

How many bytes is 2 characters?

a character in binary is a series of 8 on or offs or 0 or 1s. one of those is a bit and 8 bits make a byte so 1 byte is one character.so 2 bytes hold two characters.

How many bytes is a character stored in?

Each character is encoded as 1 to 4 bytes. The first 128 Unicode code points are encoded as 1 byte in UTF-8.

How many character can be saved or stored in one byte?

1 byte may hold 1 character. For Example: Refer Ascii values for each character & convert into binary. This is how it works. 2^8 = 256 Characters.

How many digits can a byte store?

Data is often expressed in bytes, which are composed of eight binary digits. Bytes are used to represent all sorts of data, including letters, numbers and symbols. Each byte is made up of a string of bits that must be used in the larger unit for applications.


2 Answers

1 byte may hold 1 character. For Example: Refer Ascii values for each character & convert into binary. This is how it works.

enter image description here value 255 is stored as (11111111) base 2. Visit this link for knowing more about binary conversion. http://acc6.its.brooklyn.cuny.edu/~gurwitz/core5/nav2tool.html

Size of Tiny Int = 1 Byte ( -128 to 127)

Int = 4 Bytes (-2147483648 to 2147483647)

like image 66
Venkatesh K Avatar answered Nov 12 '22 05:11

Venkatesh K


Yes, 1 byte does encode a character (inc spaces etc) from the ASCII set. However in data units assigned to character encoding it can and often requires in practice up to 4 bytes. This is because English is not the only character set. And even in English documents other languages and characters are often represented. The numbers of these are very many and there are very many other encoding sets, which you may have heard of e.g. BIG-5, UTF-8, UTF-32. Most computers now allow for these uses and ensure the least amount of garbled text (which usually means a missing encoding set.) 4 bytes is enough to cover these possible encodings. I byte per character does not allow for this and in use it is larger often 4 bytes per possible character for all encodings, not just ASCII. The final character may only need a byte to function or be represented on screen, but requires 4 bytes to be located in the rather vast global encoding "works".

like image 29
Rod Lloyd Avatar answered Nov 12 '22 03:11

Rod Lloyd