1.4.1 Data Types - Done Flashcards

(35 cards)

1
Q

Name each primitive data type

A

-Integer
-Real/floating point
-Character
-String
-Boolean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the purpose of data types?

A

They are needed so the computer knows how to store, process and interpret data correctly so that only valid operations are performed on data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an integer?

A

A whole number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a real/floating point data type?

A

A decimal number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a character?

A

A single letter, digit or symbol

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a string?

A

A sequence of characters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a boolean data type?

A

A data type with only 2 possible values – true or false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What types of data can be represented in binary?

A

Numeric, text, image and sound

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How is binary used to represent text?

A

Through their use of the character sets ASCII and Unicode. Each character is given a unique binary code. Increasing the number of bits for each character increases the number of possible characters that can be stored

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How is binary used to represent numbers?

A

Positive denary numbers can be represented through binary. Negative binary numbers can be stored using Sign and Magnitude and Two’s Compliment. Floating point binary can be used to store decimal numbers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How is binary used to represent images?

A

Images are split into pixels. Each pixel is given a binary value which represents colour.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How is binary used to represent sound?

A

Analogue sound is sampled. A sample is a reading that is taken at a certain point and stored as a binary number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Why do computers use binary?

A

Computers are made up of switches which have 2 states: on and off. This can be easily represented using binary as it also has 2 states that can represent on and off: 1 and 0.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Describe Sign and Magnitude

A

The number is written the same as in regular binary, however the left-most bit has become a sign bit (no longer representing a weighted value, but instead a sign) with 1 representing a negative number and 0 for if the number is positive.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Describe Two’s complement

A

Negative numbers are represented starting from 11111111 as the denary value -1.

Starting from the right-most digit, you write the binary number exactly how it would appear in regular binary, up to and including the first 1. From that point onwards, swap every 0 for a 1 and vice versa.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

State the advantages of storing values using Two’s complement rather than Sign and Magnitude

A
  • Calculations are easier to perform
  • Two’s complement allows for a larger range of numbers to be stored
  • It has only one representative station for 0
  • No additional hardware is required
17
Q

Describe how to do binary subtraction using the borrowing method

A

1 - 1 = 0
1 - 0 = 1
0 - 0 = 0
0 - 1 = 1, make the next digit of 1 a 0 and the digit to the right of it a 2

18
Q

Describe how to do binary subtraction using Two’s complement

A

Add the negative version of one number to the positive of the other number to get the two’s complement form of the result.
[a - b = a + (-b)]

19
Q

What are the benefits of using hexadecimal over binary?

A

-Hexadecimal values are shorter than binary so 4 bits can be represented using one character
-This means they are faster, and more reliable to write down and read

20
Q

How are decimal numbers represented in floating point binary?

A

The mantissa of a floating point number holds the actual digits of the value and represents the precision of the number. It’s usually 5 bits long.

The exponent controls the size of the number as it governs where the decimal point is positioned. It’s usually 3 bits long. The exponent is written in Sign and magnitude.

The decimal point starts between the first and second digits. If the exponent is positive the decimal moves right, if it’s negative it moves left.
Each digit after the decimal represents 1/2^n (with n increasing the lower the digit is).

21
Q

What is the benefit of using a normalised form when representing data as a floating point number?

A
  • It allows for greater accuracy from the given number of bits.
  • The representation of each binary value is unique.
22
Q

Describe how a normalised number should appear

A

A floating point where the mantissa starts with 01 if positive or 10 if negative.
The normal exponent should be the difference between where the decimal point would be based on the original exponent and where it is after normalisation (negative if the normalised is further right, positive if it’s further left)

23
Q

How do you perform a logical shift?

A

By moving all the bits in a binary number left/right a set number of places.
In a right shift, the right most bits should be discarded. In a left shift, the empty righthand bits should be filled with zeros.

24
Q

What do right and left shifts do to the numbers?

A

A right shift divides the number by 2, a left shift multiplies the number by 2.

25
What is a mask?
A binary pattern used with bitwise operations to manipulate specific bits within a binary value.
26
Describe the use of the AND mask
Both bits are needed to be 1 for the result to be 1. An AND mask is used to clear (Set to 0) specific bits, as any bit ANDed with 0 becomes 0 and with 1 stays the same.
27
Describe the use of the OR mask
1 or both bits need to be 1 for the result to be 1. An OR mask is used to set (turn on) specific bits as any bit ORed with 1 becomes 1 and with 0 stays the same.
28
Describe the use of the XOR mask
1 bit (but NOT both) needs to be 1 for the result to be 1. A XOR mask is used to toggle (invert) specific bits as any bit XORed with 1 flips and, when XORed with 0 stays the same.
29
Define a character set
A list of characters (that can be understood by the computer) where each character is given a unique binary value that is stored instead of the character
30
Describe ASCII
The American Standard Code for Information Interchange uses 7 bit binary (128 characters) to represent characters. Extended ASCII uses 8 bits (256 characters).
31
What's the advantage of ASCII?
It's simple and compact and takes up less memory.
32
What's the disadvantage of ASCII?
The limited number of bits means it can only store English characters, and doesn't have the space to store a wider variety of characters.
33
Describe Unicode
Unicode is a character set that uses up to 32 bits to represent characters using binary numbers.
34
What is the advantage of Unicode?
It includes over 140,000 characters, allowing consistent representation of text across different devices and platforms and for characters from a variety of languages and writing systems to be represented digitally.
35
What is the disadvantage of Unicode?
The greater number of bits it utilises means it take ups more memory than ASCII.