1.4.1 - Data Types Flashcards

(41 cards)

1
Q

What are the five primitive data types?

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 an Integer data type?

A

A whole number, including zero and negatives, without a fractional part.

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

What is a Real/Floating Point data type?

A

A positive or negative number that can have a fractional part.

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

What is a Character data type?

A

A single symbol, including letters, numbers, and symbols.

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

What is a String data type?

A

A collection of characters, used for storing text.

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

What is a Boolean data type?

A

A data type restricted to the values True and False.

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

How are positive integers represented in binary?

A

Using base-2, where each bit represents a power of two.

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

What is the least significant bit (LSB)?

A

The rightmost bit in a binary number, representing 2^0 (1).

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

What is the most significant bit (MSB)?

A

The leftmost bit in a binary number, representing the highest power of two.

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

What is a byte?

A

A group of 8 bits.

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

What is a nybble?

A

Half a byte; a group of 4 bits.

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

Convert the binary number 1101 to decimal.

A

(81)+(41)+(20)+(11) = 13

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

Convert the decimal number 47 to binary.

A

101111 (or 00101111 as a byte)

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

What are the four rules for binary addition?

A

0+0+0=0; 0+0+1=1; 0+1+1=10; 1+1+1=11

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

Add the binary numbers 1011 and 1110.

A

1011 + 1110 = 11001

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

What is Sign Magnitude representation?

A

A method where the leftmost bit indicates the sign (0=positive, 1=negative).

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

How is -173 represented in 9-bit Sign Magnitude if 173 is 10101101?

A

110101101 (1 added for negative sign)

18
Q

What is Two’s Complement?

A

A method where the MSB has a negative weight, simplifying arithmetic.

19
Q

How do you find the Two’s Complement of a number?

A

Flip all the bits and add 1.

20
Q

What is the 8-bit Two’s Complement of 7?

A

00000111 -> 11111000 -> 11111001

21
Q

Subtract 12 from 8 using 5-bit Two’s Complement.

A

8 (01000) + (-12 = 10100) = 11100 (which is -4)

22
Q

What base is hexadecimal?

23
Q

What digits and letters are used in hexadecimal?

A

0-9 and A-F (where A=10, B=11, …, F=15).

24
Q

Convert the hexadecimal number 4E7F to decimal.

A

(44096)+(14256)+(716)+(151) = 20095

25
Convert the hexadecimal number B2 to binary.
B (11 -> 1011), 2 (2 -> 0010) -> 10110010
26
Convert the hexadecimal number 4C3 to decimal.
(4*256)+(12*16)+(3*1) = 1219
27
What are the two parts of a floating point number?
Mantissa and Exponent.
28
What is the purpose of normalisation in floating point?
To maximise precision by ensuring the mantissa starts with 01 (positive) or 10 (negative).
29
How do you add two floating point numbers?
Make exponents the same, add mantissas, then normalise the result.
30
How do you subtract two floating point numbers?
Make exponents the same, convert subtrahend to two's complement, add, then normalise.
31
What is a logical shift left?
Moving all bits left, adding trailing zeros; equivalent to multiplication by 2^n.
32
What is the result of a logical shift left by 3 on 10010110?
10010110000
33
What is a bitmask?
A binary pattern used with a logic gate (AND, OR, XOR) to manipulate specific bits.
34
What does an AND mask do?
Returns 1 only if both corresponding bits are 1; used to 'extract' bits.
35
What does an OR mask do?
Returns 1 if at least one corresponding bit is 1; used to 'set' bits.
36
What does an XOR mask do?
Returns 1 if corresponding bits are different; used to 'toggle' bits.
37
What is a character set?
A published collection of codes and their corresponding characters.
38
What is ASCII?
American Standard Code for Information Interchange; uses 7 bits for 128 characters.
39
What is the main limitation of ASCII?
Limited to 128 characters, insufficient for many languages and symbols.
40
What is Unicode?
A character set using a variable number of bits, supporting over 1 million characters.
41
What is the key advantage of Unicode over ASCII?
It can represent a vast range of characters from many languages and symbols.