PyGCSE Python Lab

Floating Point Converter

Convert between decimal and normalised floating point binary using two's complement for both mantissa and exponent. Matches the AQA A Level CS (7517) specification §4.5.4.8.

📖 Learn Step-by-Step
12-bit total

Click bits to toggle between 0 and 1.

Mantissa

±2⁻12⁻22⁻32⁻42⁻52⁻62⁻7

Exponent

-8421
Decimal value

0

Mantissa = 0

Exponent = 0

Normalised: Yes

Working:

  1. Sign bit = 0 → positive number
  2. Mantissa: 0 = 0
  3. Exponent (two's complement): 0000 = 0
  4. Result: 0 × 2^0 = 0

Floating Point Practice Questions

Q1 · 3 marks
Question 1

FP to Decimal (8-bit mantissa, 4-bit exponent)

0/3 marks
A normalised floating point number uses an 8-bit mantissa and a 4-bit exponent, both in two’s complement. The mantissa is 01101000 and the exponent is 0011. Calculate the decimal value.

Mantissa

±2⁻¹2⁻²2⁻³2⁻⁴2⁻⁵2⁻⁶2⁻⁷
01101000

Exponent

−8421
0011

Your Answer (decimal value):

Q2 · 3 marks
Question 2

FP to Decimal (negative mantissa)

0/3 marks
A normalised floating point number uses a 6-bit mantissa and a 4-bit exponent, both in two’s complement. The mantissa is 101100 and the exponent is 0010. Calculate the decimal value.

Mantissa

±2⁻¹2⁻²2⁻³2⁻⁴2⁻⁵
101100

Exponent

−8421
0010

Your Answer (decimal value):

Q3 · 3 marks
Question 3

Decimal to FP (positive value)

0/3 marks
Convert the decimal value 2.75 to normalised floating point using an 8-bit mantissa and 4-bit exponent (both two’s complement). Click the bits to set the mantissa and exponent.

Given decimal value: 2.75

Mantissa

±2⁻¹2⁻²2⁻³2⁻⁴2⁻⁵2⁻⁶2⁻⁷

Exponent

−8421

Click bits to toggle between 0 and 1.

Q4 · 3 marks
Question 4

FP to Decimal (simple positive)

0/3 marks
A floating point number has mantissa 01010000 (8-bit) and exponent 0100 (4-bit), both two’s complement. Calculate the decimal value.

Mantissa

±2⁻¹2⁻²2⁻³2⁻⁴2⁻⁵2⁻⁶2⁻⁷
01010000

Exponent

−8421
0100

Your Answer (decimal value):

Q5 · 3 marks
Question 5

Decimal to FP (negative value)

0/3 marks
Convert the decimal value -3.5 to normalised floating point using an 8-bit mantissa and 4-bit exponent (both two’s complement). Click the bits to set the mantissa and exponent.

Given decimal value: -3.5

Mantissa

±2⁻¹2⁻²2⁻³2⁻⁴2⁻⁵2⁻⁶2⁻⁷

Exponent

−8421

Click bits to toggle between 0 and 1.

Quick reference — how AQA floating point works

AQA represents floating point numbers as mantissa × 2exponent. Both mantissa and exponent use two's complement.

Mantissa (two's complement fixed-point):

  • MSB is the sign bit (0 = positive, 1 = negative)
  • Remaining bits represent the fractional part: 2⁻¹, 2⁻², 2⁻³ …
  • Positive value: simply sum the place values
  • Negative value: −1 + sum of fractional place values

Normalisation rules:

  • Positive normalised: mantissa starts 0.1…
  • Negative normalised: mantissa starts 1.0…
  • Normalisation maximises precision by avoiding leading zeros/ones

Exponent (two's complement integer):

  • Standard two's complement — MSB has negative weight
  • For 8 bits: range −128 to +127