2.1.10+Data+Representation

= = =__**Binary Data Representation**__= Binary is a set of bits (8 bits making up one byte). Each bit is stored as either a 0 or a 1.

The binary code is a base 2 system (humans usually use the base 10 system) and is constructed using the powers of 2 according to the following pattern. The numbers of bits, that can be used, determine how many different values you can encode. For a 1 byte (8 bit) system, these would be the values, for example:
 * < Decimal number ||= 128 ||= 64 ||= 32 ||= 16 ||= 8 ||= 4 ||= 2 ||= 1 ||
 * Power of 2 || media type="custom" key="8688358" || media type="custom" key="8688354" || media type="custom" key="8688352" || media type="custom" key="8688350" || media type="custom" key="8688348" || media type="custom" key="8688346" || media type="custom" key="8688344" || media type="custom" key="8688340" ||
 * Binary number || 10000000 || 01000000 || 00100000 || 00010000 || 00001000 || 00000100 || 00000010 || 00000001 ||

Therefore 00000000 would be 0 in decimal and 11111111 would be 255 in decimal. So with one byte one can store up to 256 different values.

To store any data (including text) digitally, it has to be converted to binary. There are several encodings to do so for text, Unicode being currently used commonly, which originates from ASCII.
 * __Text storage__**

__ASCII__ On both Windows/DOS and Unix systems, the 128 most commonly-used characters are each represented by a sequence of 7 bits known as the character’s ASCII code. They are traditionally stored as bytes (8 bits), i.e. the 7-bit ASCII code plus a leading zero. The characters include letters, digits, punctuation marks, and nonprintable control characters such as the backspace, tab, carriage return, etc.

__ Unicode __ Unicode is a further development of ASCII. Characters are now stored in 2 bytes (as oppose to 1 byte as in ASCII) and therefore more characters can be stored and displayed, allowing for an international character set. The first 128 characters of the ASCII and Unicode code are the same.

Images are also stored in a binary format. Each color is represented by a different binary code. Nowadays modern computers use a color depth of 32 bit; i.e. media type="custom" key="8688360" colors can be displayed. The lower the color depth, the less bits are used and the less colors there are available.
 * __Images and binary__**

Below a comparison of an image with different color depths:
 * **Origional (media type="custom" key="8701654"=256 colors)** || media type="custom" key="8701656"**=16 colors** ||
 * [[image:origional.png]] || [[image:4_bit_(16_farben).png]] ||
 * media type="custom" key="8701658"**=8 colors** || **media type="custom" key="8701662"=4 colors** ||
 * [[image:3_bit_(8_farben).png]] || [[image:2_bit_(4_farben).png]] ||
 * media type="custom" key="8701666"**=2 colors** ||  ||
 * [[image:1_bit_(2_farben).png]] ||  ||

Written by Jocbe Last update: 17. March 2011

Sources:
 * Arpingstone. "File:Autumn.scene.at.westonbirt.arp.jpg." Wikimedia Commons. Web. 15 Mar. 2011. .
 * Jones, Richard. Computer Science Java Enabled. Victoria: IBID Press, 2004.