Floating Point Arithmetic Flashcards

1
Q

How are integers represented in computing?

A

Integers can be represented exactly using a fixed number of bits.

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

What is the largest unsigned integer that can be represented with n bits?

A

2^n - 1

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

How are negative integers represented in computing?

A

Using two’s complement notation.

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

Why do we need floating point representation?

A

Many scientific and engineering calculations involve non-integer values that require fractional representation.

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

Give an example of a scientific value that requires floating point representation.

A

Mass of an electron: 9.109 × 10^−31kg

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

What key feature makes floating point representation different from integer representation?

A

The decimal point can float, allowing for a wide range of values.

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

What components make up a floating point number?

A
  1. Significand/Mantissa
  2. Exponent
  3. Base
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does the exponent do in floating point numbers?

A

It determines how much the significand is scaled by the base

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

How would 9.109 × 10−31 be represented in floating point?

A
  • Significand: 9.109
  • Base: 10
  • Exponent: -31
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is IEEE 754?

A

The most widely adopted standard for floating point arithmetic.

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

What does IEEE 754 specify?

A
  • Number representations (e.g., single precision, double precision)
  • How operations like addition, subtraction, multiplication, and division behave
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the two most commonly used floating point precisions in C?

A
  • Single Precision: 32-bit , float
  • Double Precision: 64-bit, double
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Why is double precision preferred for scientific computing?

A

It provides greater accuracy and range compared to single precision

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

What happens if a number exceeds single precision limits?

A

It is represented as infinity (inf)

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

In what applications might single precision be sufficient?

A

Machine learning and graphics.

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

How many bits does double precision floating point use?

A

64 bits (8 bytes)

17
Q

How are the 64 bits divided in double precision floating point?

A
  • 52 bits for the mantissa
  • 11 bits for the exponent
  • 1 bit for the sign
18
Q

How is a normalized floating point number represented in IEEE 754?

A

x=±(1.b{1}.b{2}…b{52}) x 2^(a{1}.a{2}…a{11})-1023
where:
- b{1}, b{2}, …b{52} are the mantissa
- a{1}, a{2}, …a{11} are the exponent bits

19
Q

What is the smallest normalised double precision number?

A

2^(−1022) ≈ 10^(−308)

20
Q

What is the largest normalised double precision number?

A

(2−2^(−52)) × 2^(1023) ≈ 10^(308)

21
Q

Why are floating point numbers not always exact?

A

Because they have finite precision, leading to rounding errors.

22
Q

What is machine epsilon?

A

The smallest difference between 1 and the next representable number, approximately: 2^(−52) ≈ 10^(−16)

23
Q

Why is machine epsilon important?

A

It determines the smallest detectable rounding error in double precision calculations.

24
Q

What are some cases where floating point arithmetic fails?

A
  • 1.0/0.0 → Infinity (inf)
  • 0.0/0.0 → Not a Number (NaN)
  • sqrt{-1.0} → Not a Number (NaN)
  • Operations that exceed floating point range → Overflow or underflow
25
What is a *normalised* floating point number?
A number where exponent bits are neither all zeros nor all ones
26
What happens if all exponent bits are zeros?
The number is a subnormal number, with reduced precision.
27
What happens if all exponent bits are ones?
- If mantissa = 0 → Infinity (`+inf` or `-inf`) - If mantissa ≠ 0 → Not a Number (`NaN`)
28
What are the five floating point exceptions in IEEE 754?
1. Overflow → Result is too large → `inf` 2. Underflow → Result too small → `0` or subnormal 3. Divide by Zero → `inf` 4. Invalid → `NaN` 5. Inexact → Rounded result
29
What is peak performance (`R_{peak}`)?
The *theoretical maximum performance* of a system, measured in FLOP/s.
30
How is `R_{peak}` used in HPC rankings?
It is listed in Top500 rankings, but `R_{max}` is used for final ranking.
31
What system factors determine `R_{peak}`?
1. Number of sockets 2. Number of processor cores per socket 3. Clock frequency (GHz) 4. Floating point operations per cycle
32
What features increase the number of operations per cycle?
- Vector instructions (e.g., AVX, SVE) - Fused Multiply-Add (FMA) operations
33
Given: - 2 sockets - 6 cores per socket - 2.8 GHz clock speed - 4 operations per cycle What is the compute node `R_{peak}`?
`R_{peak}` = 2×6×2.8×4 = 134.4 GFLOP/s
34
If a cluster has 192 compute nodes, where each compute node's `R_{peak}` = 134.4 GFLOP/s, what is its peak performance?
192×134.4 GFLOP/s = 25.2 TFLOP/s