Chapter 6 - Data types Flashcards
What is a primitive data type?
One provided by a programming language
What are 4 primitive data types?
Integers,
Characters,
Booleans,
Strings
Def a character set
A set of characters represented in binary by a computer
What mask and operation would you use to clear bits?
an AND operation where 1 preserves the bit and 0 clears the bit
What mask and operation would you use to set bits?
an OR operation where a 1 sets a bit and a 0 leaves a bit
What mask and operation would you use to toggle bits?
an XOR operation where a 1 toggles a bit and a 0 preserves a bit
What is the difference between Kibi and Kilo?
Kibi represents 1024 and Kilo is 1000. Kibi is base 2 increasing in powers of 10 whereas Kilo is base 10 increasing in powers of 3.
Name 3 character sets
ASCII, UNICODE (UTF-16), UTF-32
What is the formula for finding the range of numbers representable by a number of bits ānā using twos complement?
- 2^(n-1) - 1 to 2^(n-1) - 1
What is the MSB in binary and where is it?
The MSB is the most significant bit and is the one on the far left.
How does sign and magnitude work when representing negative numbers?
The most significant bit is simply replaced with a sign bit. 0 being positive and 1 being negative
Why is floating point binary necessary when fixed point already exists?
It is much more flexible and accessible than fixed point and can create much larger numbers than fixed point binary can.
Why are fixed point binary numbers bad?
They have a reduced range and precision for the number of bits used
What will the first bit after the decimal point be in a normalised positive number?
The sign but will be 0 and the msb always 1
What will the first bit after the decimal point be for a normalised negative number?
The sign bit will always be 1 and the msb always 0