1.4.1 - Data types Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What are the main data types used?

A

Integer (int): Whole number values with no decimal point (7, -45, 200)
Float (float): Numbers with decimal or fractional parts (36.8, -13.1, PI)
Character (char): Single letter, digit, symbol or control code (D, h, 8, )
String (str): A string of characters (“Word”, Gh8kfgj
)
Boolean (bool): True or false flag

All data stored or used by computers in binary

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

What base does binary use?

A

Base of 2

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

How do you convert a denary number to binary?

A

Use this table

128, 64, 32, 16, 8, 4, 2, 1

And keep adding a 1, where the table number can go into the denary number, and a 0 where the table value is too large. for example 70 would be:

128, 64, 32, 16, 8, 4, 2, 1
0,1,0,0,0,1,1,0

THIS IS FOR REPRESENTING AS A POSITIVE NUMBER

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

How do you represent a negative denary in binary?

A

Sign and Magnitude:

In denary, store a sign bit (positive or minus) as the most left hand bit (0 for positive and 1 for negative)

Two’s Complement:

The processing require to handle sign and magnitude is complicated so using twos complement is to flip all the numbers from the most significant bit

01000110 is positive 70
10111010 is negative 70 as i have flipped all the numbers past the first 1.

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

What are the outcomes when adding binary numbers?

A

The possibilities are:
1+0 = 1 (1)
1+1 = 10 (2)
1+1+1= 11 (3)

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

What are the outcomes when subtracting binary numbers?

A

The possibilities are:
1-0 = 1 (1-0)
1-1 = 0 (1-1)
10-1= 1 (2-1)

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

What base is hexadecimal?

A

Hexadecimal is a number system with a base of 16.

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

How to convert between binary, denary and hex?

A

Use digits to represent the values 0 to 9 but use A to F for the extra digits to represent the values 10 to 15 in
hexadecimal.

To represent a denary number in hexadecimal, repeatedly divide by 16, recording the remainders until you reach 0.

To convert a hexadecimal to a binary value, convert each hexadecimal digit to its equivalent binary nibble (4 binary
digits).

To convert a binary value to hexadecimal, divide the binary value into nibbles and convert to the hexadecimal
equivalent.

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

How do you convert floating points to binary (decimal)

A

To tell if a number is positive or negative, simply look at the first binary digit: 0 is positive, 1 is negative. There is a
process to convert positive floating point to unsigned binary:
- Split into mantissa and exponent.
- Use the exponent to float the binary point back into place.
- Converted to denary.

For negative values starting with a 1:
- Split into mantissa and exponent.
- Evaluate the exponent
- Move the binary point one place to the left.

The number of bits chosen for the mantissa and exponent affects the range and the accuracy of the values that can be
stored.

If more bits are used for the mantissa, the value stored is more accurate.

But the range is limited by the small exponent.

If more bits are used for the exponent, the range of values stored is greater.

But the accuracy is limited by the smaller mantissa.

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

What does shifting do?

A

A logical shift moves the whole binary value to the left or right.

Shifting left is equivalent to multiplying by 2.

Shifting right is equivalent to dividing by 2.

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

How can masking be done with logical operations?

A

Masking with logical operations

NOT can be used to perform a bitwise swap of values in a binary number.

AND can be used to exclude bits by placing a 0 in the appropriate bit in the mask.

OR can be used to reset bits by placing a 1 in the appropriate bit in the mask.

XOR can check if corresponding bits are the same.

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

What is a character set?

A

The characters or symbols that can be recognised, represented, interpreted, understood and used by a computer.

Each required character is represented by a unique binary code or number so each symbol is distinguishable from
all others.

Number of bits used for one character = 1 byte.

Normally determinable by reference to the characters available on a keyboard e.g. digits, letters and symbols.

May include control characters.

Example Code: ASCII/UNICODE use 8/16 bits per character.

Number of characters will tend to be a power of 2.

Allows keys to have different characters.

The more characters required, the more bits in each code used for extended character sets.

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

What is ASCII?

A

ASCII: Each character of the alphabet and some special symbols and control codes are represented by agreed
binary patterns using 8 bits.

The number of characters in the character set is limited to 256, making it impossible to display the wide range of
characters for other alphabets or symbols sets.

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

What is Unicode?

A

UNICODE: Is a character set mapping different binary values to characters on screen.

Originally a 16-bit coding system that assigns a unique code to all the possible symbols available throughout the
world.

All symbols in different languages, platforms and programs have unique codes.

Updated to remove the 16-bit restriction by using a series of code pages with each page representing the chosen
language symbols.

Continues to grow as it is not a fixed size set so supports a very large number of characters, currently allowing over 100000 symbols represented.

It is backward compatible with ASCII so the original ASCII representations have been included with the same numeric values.

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