2.3 Data Representation and Data Types (Binary, Hex, and Denary)

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/50

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

51 Terms

1
New cards

Bit

A bit is the smallest unit of data in computing. It is a binary digit that can hold either the value of 0 or 1.

2
New cards

Byte

A byte is a group of binary digits operated on as a unit. In most computer systems, a byte is made up of 8 bits.

3
New cards

Word

A word is the total number of bits that can be manipulated as a single unit by the CPU.

4
New cards

What is binary?

Base 2 system 0/1 whihc is computers language show with a 2 subscript2

5
New cards

What is hexadecimal

Base 16 with going from 1-F (1-9 Then A-F representing 1-15) shown as16

To convert divide by 16 to get the second digit and the remainder is the first

6
New cards

What is denary?

Base 10 decimal system with numbers10 1-9

7
New cards

Boolean

A Boolean data type represents truth values and can only take on two possible values: true or false.
May be stored in a single Bit as 1 if true and 0 if false.

8
New cards

Character

A character data type is used to store a single character, such as a letter, digit, or symbol. Characters are often represented using character encoding standards like ASCII or Unicode.
ASCII Character: 1 byte (8 bits). ASCII characters range from 0 to 127.

9
New cards

String

A string is a sequence of characters used to represent text. Unlike single characters, strings can vary in length.
The storage requirement for a string depends on its length and the encoding used.
For example, a string of length nnn in ASCII would require nnn bytes.

10
New cards

Integer

An integer data type is used to store whole numbers (i.e., numbers without a fractional part). Integers can be signed (allowing negative values) or unsigned (positive values only).
The storage requirement is 8-bit (1 byte) Integer: Ranges from −128-128−128 to 127127127 (signed) or 000 to 255255255 (unsigned).

11
New cards

Real

A real (or floating-point) data type is used to represent numbers with fractional parts, allowing for the representation of decimal points.
The storage requirement is 32-bit(4 bytes)

12
New cards

Binary addition

Use carrying for 2 ones just carry and put a zero. for/ one one place a 1

Start from least significant bit (left) and show overflow with a bracket

<p>Use carrying for 2 ones just carry and put a zero. for/ one one place a 1</p><p></p><p>Start from least significant bit (left) and show overflow with a bracket</p>
13
New cards

Underflow error

An underflow error occurs when a number is too small to be stored in the bits available. e.g., 0.00005 for a 3-bit value

Generally a number close to zero will round dound to zero as it cannot accutratly store teh data

14
New cards

Overflow error

An overflow error occurs when a binary value is too large to be stored in the bits available (not enough bits which can change signs and reduce precision). (e.g., 128 for an 8-bit value)

15
New cards

How to calculate absolute error

Absolute = original - new

The difference between the original number and the representation after truncation

16
New cards

How to calculate relative error

Relative = (absolute error /original num) * 100 %

17
New cards

What is sign and magnitude?

Makes use of the MSB to show the sign of a binary number.

<p>Makes use of the MSB to show the sign of a binary number.</p>
18
New cards

Why is sign and magnitude not used?

  • Has to check the sign during binary arithmetic which creates overheads due to extra logic required (check sign, do calculation, update sign)

  • You also lose MSB also so you cant store as high of a number

19
New cards

2's Complement

Method for representing signed (positive, negative, and zero) integers.
It works by starting with either -128 or 0 and adding on for every one that is there e.g.
-42 -> 11010110 (in two's complements)
-128+64+16+4+2 = -42

<p>Method for representing signed (positive, negative, and zero) integers.<br>It works by starting with either -128 or 0 and adding on for every one that is there e.g.<br>-42 -&gt; 11010110 (in two's complements)<br>-128+64+16+4+2 = -42</p>
20
New cards

How to convert into 2’s complement

  1. Start with binary positive absolute value

  2. Invert all bits (1→ 0 then 0→1)

  3. Add 1

The MSB acts as the starting point and shows the sign

21
New cards

How would we binary subtract?

You would invert the subtracted number into 2’s complement then add them and ignore any overflow that occurs

e.g.

16 - 12 = 10000 - 01100

16 + -12 = 10000 + 10100 = (1)00100 = 4 when overflwo ingnored

22
New cards

Binary Multiplication?

Use column multiplication (1×1 = 1 and timsing by zero equals 0)

<p>Use column multiplication (1×1 = 1 and timsing by zero equals 0)</p>
23
New cards

Positive Whole Numbers (base 10) in Binary

The example in the picture represents 42 in 8-bit binary.

When representing a positive number in binary, it always starts from 0.

42 -> 00101010

This is wasteful, as zero can be represented twice

<p>The example in the picture represents 42 in 8-bit binary.</p><p>When representing a positive number in binary, it always starts from 0.</p><p>42 -&gt; 00101010</p><p></p><p><em>This is wasteful, as zero can be represented twice</em></p>
24
New cards

Negative Whole Numbers (base 10) in Binary (2 comp)

The example in the picture represents -42 in 8-bit binary.
When representing a negative number in binary, it always starts from 1.
-42 -> 11010110

<p>The example in the picture represents -42 in 8-bit binary.<br>When representing a negative number in binary, it always starts from 1.<br>-42 -&gt; 11010110</p>
25
New cards

What is a BCD?

Binary coded decimal (just binary and not twos complement) It will say if its twos complement.

26
New cards

Arithmetic and Logical Left-shift of binary

Left-shift means you are multiplying the binary by 2

In Arithmetic left-shift, if the binary starts with 1 that is, it's minus, you will keep the minus when you left shift.
Example: -42 -> 11010110 will be become 10101100
-128+32+8+4 = -84

In Logical left-shift, if the binary starts with 1, it will become 0, that is, the binary will become positive.
Example: -42 -> 11010110 will become 01010100
64+16+4 = 84

27
New cards

Arithmetic and Logical Right-shift of binary

Right-shift means you are dividing the binary by 2

In Arithmetic right-shift, if the binary starts with 1 that is, it's minus, you will keep the minus when you left shift.
Example: -42 -> 1101011 will be become 11101011
-128+64+32+8+2+1 = -21

In Logical right-shift, if the binary starts with 1, it will become 0, that is, the binary will become positive.
Example: -42 -> 11010110 will become 00010101
16+4+1 = 21

28
New cards

Whats a shift function?

Shifts all of the digits in a binary function to multiply or divide by powers of 2

29
New cards

Types of shift functions and what they each do

Logical shift - Shifts each binary digit with each vacted bit represented as a 0 (1011 → 1001 as the sign will stay the same)

Arithmetic shift - SImilar to logical but when performed to the right the sign bit retains its current value, which is good for negative numbers (1011 → 1101, which would be more accurate)

30
New cards

How do under/overflows affect shifts

1000 → 0000 would mean that you lose precision with the shift as we generally ignore overflows due to assigned bits

31
New cards

Logical vs Arithmetic shift?

Logical doesnt preserve vacant bits and Arithmetic shift moves bits and preserves the sign

32
New cards

Pros and cons of logical

+Simple multiplication and division

-Not suitable for signed numbers

33
New cards

Pros and cons of arithmetic?

+Preserves sign bit (good for signed nums and supports accuracy of calcs)

-Just a logical shift when going left

34
New cards

Real Numbers

Numbers with decimal places like 2.5 or 3.141592654

35
New cards

Standard Form

Large numbers represented as Mantissa x 10^exponent
0.65625 X 2^6 represent 42

36
New cards

What is fixed point?

Where the decimal point is fixed (e.g. 4 bits before and 4 after)

<p>Where the decimal point is fixed (e.g. 4 bits before and 4 after)</p>
37
New cards

What is Normalisation?

Converting a mantissa into a set for where the mantissa (where -1 =< mantissa < 1) in twos a complement so it is more precise. You would perform this be removing any leading (0s or 1s, 0 for normal and 1 for negative num) before the point and move the floating point.

38
New cards

What is normalisation used for?

Making a binary real shorter or more space efficient (gives better precision for adding to it)

39
New cards

Exponent and Mantissa

Mantissa x 10^exponent
Mantissa must be between -1 and 1
-1 <= Mantissa < 1

Exponent is part of a number indicating the power of the base

40
New cards

How to get exponent and mantissa

You will use a calculator to divide the number by 2 each time until you get an answer that's between 0.5 and 1. The answer is the mantissa. The number of 2 you use to get the answer is the exponent.

42 = 42 x 2^0 (no division)
42 = 21 x 2^2 (first division)
42 = 10.5 x 2^2 (second division)
42 = 5.25 x 2^3 (third division)
42 = 2.625 x 2^4 (fourth division)
42 = 1.3125 x 2^5 (fifth division)
42 = 0.65625 x 2^6 (sixth division)

The exponent is how many times the mantissa has been shifted during normalisation (as there will only be one number before the point)

41
New cards

What is range and precision?

Range - How large of a number representable

Precision - How precise a number you can represent

42
New cards

16-bit Floating Point

16-bit floating point uses 8-bits for the Mantissa and 8-bits for the Exponent.
Both parts could use Sign & Magnitude or Two's Complement representation.

43
New cards

Representing Mantissa in binary

The image show how to represent a Mantissa of 0.65625

<p>The image show how to represent a Mantissa of 0.65625</p>
44
New cards

Representing Exponent in binary

The image show how to represent an exponent of 6

<p>The image show how to represent an exponent of 6</p>
45
New cards

16 bit floating point representation

knowt flashcard image
46
New cards

Real Number to fixed point binary

The image shows 25.57 in fixed point binary.

Convert the 25 to binary, then convert .75 using 1/2, 1/4 and so on.

<p>The image shows 25.57 in fixed point binary.<br><br>Convert the 25 to binary, then convert .75 using 1/2, 1/4 and so on.</p>
47
New cards

Difference between Floating Point and Fixed Point

Floating point
• It has set number of bits for mantissa and exponent
• trade-off between accuracy v range (as point moves)
• larger mantissa leads to greater accuracy
• larger exponent leading to greater range of numbers being represented
• It is not possible to represent zero.

Fixed point
• not flexible and has a set range and level of accuracy
• is less complex.

48
New cards

Floating point positives and negatives?

+Scalable - very large and small values can be represented+

+Precise and large range - for smaller numbers precision can be given and larger numbers can have the range

+Realistic - Can present a higher array of small numbers (good for calcs)

-Precise but still limited - by mantissa size

-Precision errors - rounding and truncation errors can occur as not all decimal fractions can be used

-Representation errors - Precision is not fixed so small representation errors may occur (like 0.1 not easily represented)

49
New cards

Hex to denary (base 10)

AD9C
(10 x 4096) + (13 x 256) + (9 x 16) + (12 x 1)
40960 + 3328 + 144 + 12 = 44444

50
New cards

Base 10 to Hex

50672
50672/4096 = 12 - C
12 x 4096 = 49152
50672 - 49152 = 1520
1520/256 = 5 - 5
5 x 256 = 1280
1520 -1280 = 240
240/16 = 15 - F
15 x 16 = 240
240 - 240 = 0 - 0
50672 -> C5F0

51
New cards

Binary to Hex

10101101111011

Split into group of four

0010 1011 0111 1011

2B7B

When splitting up the Binary into group of 4, always start at the RIGHT