How
does the Computer Store Information in Bits and Bytes?
1: Unsigned integer format for representing a
limited non-negative integers: By using powers of 2 instead of 10 to encode
integers, the computer uses a binary number system to encode an integer in bits
of 0’s and 1’s (instead of 10 different digits in the decimal system).
- Exercise 1: Convert each of the following five binary numbers
(each as an 8-bit binary string, 40 bits all together) into the
corresponding decimal numbers: 01000010, 01101001, 01101111, 01101100, and
01100001. (See how to convert
between binary and decimal numbers.)
- Exercise 2: Consider 106 and 233 as two decimal numbers.
Explain in your report what the corresponding 8-bit binary numbers are.
(See how to convert between binary and decimal
numbers.)
- Note: For representing
numbers in general, (i) the signed integer format can represents both positive and
negative integers in a limited range and (ii) the single-precision and double-precision floating point formats
can represent real numbers big and small in a much larger but still
limited ranges. You can take CSCI 220 Computer Organization to know a lot
more details.
2: ASCII code for western characters and
symbols: Character are encoded in 8 bits (i.e. 1 byte) as numbers using the
ASCII character set
encoding that maps a character into a number in the range of 0 to 255. The
size of a pure text file (.txt file) in bytes is close to the number of
characters in the file since each character in a plain text file is encoded in
1 byte of memory.
- Exercise 3: Suppose the 5 bytes (i.e. 5 groups of 8 bits each)
of information in Step 1 above (i.e 01000010,
01101001, 01101111, 01101100, and 01100001) are stored as a part of a text
file to encode the information of 5 characters (8 bits for each character)
using the ASCII
character set encoding. Explain in your report what the five
characters are.
- Exercise 4: Use NotePad (or other
simple text editor) to create 4 text files (files with .txt extension on
Windows platform), each of about 100 characters, 200 characters, 400
characters, and 800 characters respectively and save them as text files.
Record and report the sizes of these files (in terms of bytes). Note that
it takes one byte to record a character. Explain in your report the
relationship between the number of characters and the file sizes you see.
- Note: For characters and symbols over the world in general, Unicode can represent a
much wider range of possible characters and symbols.
3:
BMP format for representing images:
The size of a picture in the 24-bit BMP file format in bytes is about 3 times
the number of pixels since the color of each pixel is encoded in terms of 24
bits, i.e. 3 bytes. With 8 bits each for representing the intensity of each of
the RGB components of the color.
- Exercise 5: (i) On the Windows 10
platform, hold ‘Fn’ and press the ‘Print Screen’
key to capture the screen as a picture. Open up Microsoft Paint, paste the
image into the canvass, and save it as a 24-bit bitmap file ( .BMP file). Check the file size and record it in your
report. (ii) Right click on your windows desktop and
select Display Setting to
get the information regarding the resolution of your screen. What is
your screen resolution X x Y? Record it in your report. For example,
the resolution is 1400 x 1024 for the instructor’s computer in Lib 141.
(iii) Note that if you have a screen resolution of X by Y you have
X*Y pixels on the screen in total, the BMP file uses 24 bits (i.e. 3
bytes) to record the color of each pixel, and it will take X*Y*3 bytes in
the BMP file to store the information of your screenshot. Also note
that 1 MB means 1 million bytes. Record in
your progress report whether X*Y*3 is close to the actual BMP file size.
- Note: If you are a
Mac user and do not know how to do things in #3 above accordingly on Mac,
you can simply record what you observe from what I did in the class
meeting to answer the questions from Exercise 5. If needed, you can re-examine
the recorded lecture on 03/19 for that purpose.
- Note:
There are many other formats for representing images, such as JPG,
GIF, PNG, and so forth. Also see below about common units for
measuring information storage.
Measure of computer memory capacity for storing information:
·
Bit - a single
binary digit having a value of 1 or 0
·
Byte - 8 bits
·
Kilobyte (KB): 1024 bytes (approximately
~1000 bytes)
·
Megabyte (MB
): 1024
Kilobytes (approximately ~1000
Kilobytes = approximately 1 million bytes)
·
Gigabyte (GB
): 1024
Megabytes (approximately ~1000
Megabytes= approximately 1 billion bytes)
·
Terabyte (TB
): 1024 Gigabytes (approximately
~1000 Gigabytes)
·
Gigs -- slang for
Gigabytes
·
Megs -- slang for
Megabyte
Summary of common units of storage
·
KB: About 1 thousand bytes (210=1024
bytes)
·
MB: About 1 million bytes (220=1,048,576
bytes)
·
GB: About 1 billion bytes (230=1,073,741,824 bytes)
·
TB: About 1 tera
bytes (240
bytes)