Storing letters using Binary [Ascii]
Computers store every bit of data as binary. To store a number they simply convert it to its binary equivalent. But how do they store letters, and words?
It's pretty much the same - the computer converts the letter to a number equivalent then stores the number .If you are thinking then how does the computer know that its a number not a letter, short answer - it doesn't. Longer answer, it also stores Meta data that tells it how to layout the data it has stored, which helps it get the right format.
So which number do they use for each letter? They were sensible when they created this and made a = 1, b = 2, c= 3, z = 26
Lower case and Upper case
If a = 1, what is A? it is also 1, just with a different start.
We use 8 bit binary, that means 8 numerals [1's and 0's]. When working with letters we use the first 3 to show if it is a lower case, upper case or punctuation / symbol, then the last 5 to show which number:
011 = lower case letter
010 = upper case letter
001 = punctuation [ not all punctuation has a 001 code]
For example, we know that a / A should be a 1 [DEN] - so to show that in binary:
a = 011 00001
A = 010 00001
It is worth noting that the space key ," ", is 001 00000 [it comes up on the exam from time to time when you need to convert two words from binary to letters]
Limits of ASCII
Ascii only uses 8bits [8 numerals] , and 3 of those bits indicates capital or lower case, this creates some limits:
- It only handles English letters
- It has a limited range of symbols
To get around these limits Unicode was created. This uses more bits and as a result can handle far more combinations which allows more languages and symbols to be stored.
Of course, more bits means each letter takes up more storage space than Ascii and that's the trade off. If you want smallest possible storage and don't need the extra characters then use Ascii, if you do then use Unicode.
I want to insert into a table values that contain both letters and numbers [like 'CL005' for example].
What data type should I use for my attribute ? 'number' doesn't work.
Thanks in advance !
asked Apr 14, 2020 at 13:17
2
You have no choice in most databases. You need to use a string. I would recommend varchar[]
of some sort.
Some databases support a "variant" type that can hold different types. To be honest, this is very rarely used.
answered Apr 14, 2020 at 13:19
Gordon LinoffGordon Linoff
1.2m53 gold badges606 silver badges751 bronze badges
- Science
- Computer Science
-
Flashcards
-
Learn
-
Test
-
Match
-
Flashcards
-
Learn
-
Test
-
Match
Terms in this set [41]
Short Text, Long Text, Number, Date/Time, Currency, AutoNumber, Yes/No, OLE Object, Hyperlink, Attachment, Calculated, Lookup Wizard.
Sets with similar termsSets found in the same folderOther sets by this creatorVerified questionscomputer science
Verified answer
computer science
Verified answer
computer science
Verified answer
computer science
Verified answer
Recommended textbook solutions