W5 - NUMBER SYSTEMS AND SAFE PROGRAMMING Flashcards
W5-1: Why Binary?
Unambiguous and Unequivocal state:
_ 0 or 1 for storage of a value in a bit
. Electric current in RAM, magnetic charge on HDD, magic in SSD
_ TRUE or FALSE to make a decision (Boolean logic)
. hardware uses logic gates,
. software uses Selection logic,
EX: IF statements resolve to TRUE or FALSE.
Faster Processing:
CPUs, ALUs, FPUs, GPUs are faster in binary
W5-2: Hexadecimal
_ Hex is base 16
_ Why? Hex is easier than binary.
_ 8 bit byte holds 256 values. 16 * 16 = 256 thus Hex.
0–15: One – Nine, Able, Baker, Charlie, Dog, Easy, Fox
W5-3: HTML uses Hexadecimal color codes
_ Hex codes take LESS SPACE to write than decimal and are used in HTML colour representations, as in: #XXXXXX
_ Each red, green, and blue value ranges from “00” (lowest intensity) to “FF” (highest intensity) in HEX
_ Web-safe colors
W5-4: What is BYTE?
_ A sequence of adjacent bits (binary digits) that can be operated on as a unit by a computer;
_ the smallest usable machine word;
_ nearly always eight bits, which can represent an integer from 0 to 255 or a single character of text.
W5-5: Two’s Complement
_ Positive and Negative numbers share half the bits of an integer.
_ High order bit indicates the sign.
0 is positive, 1 is negative
#W5-6: Floats and Doubles — fractions In a binary system, what value is between 0 and 1?
_ Every fractional value to the right of the decimal point is an approximation between 0 and 1.
_ Not to be used for monetary or exact values in business => Use DECIMAL data type instead
_ DECIMAL data types are essentially integers with an implied fixed decimal position.
EX: DECIMAL size 9.2 contains 1,234,567.89
_ BE VERY CAREFUL MIXING INTeger and FP types