Main Menu
Multiwingspan Home Page
Multiwingspan Games
Gnasher @ Multiwingspan
Multiwingspan Calendar
Multiwingspan Clock
About Multiwingspan
Programming
Visual Basic 6.0 Guide
Visual Basic 6.0 Examples
Turbo Pascal Guide
SWI Prolog Guide
Visual Basic 2005 Guide
Structured Query Language
Web Design
HTML Design Tasks
Introduction To HTML
Introduction To CSS
Introduction To Javascript
Notes
AS/A2 Level Computing

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /websites/LinuxPackage02/mu/lt/iw/multiwingspan.co.uk/public_html/old/templates/db.inc on line 5

A Level Computing
Floating Point Binary

Standard Form

Very large or very small denary numbers are often written in standard form. This clearly saves writing out a lot of digits. Standard form is a number between 1 and 10 multiplied by a power of 10.

For example,

5.67 x 103 = 5.67 x 1000 = 5670
6.23 x 10-2 = 6.23 x 0.01 = 0.0623

To convert a decimal number to standard form, move the decimal point so that the number lies between 1 and 10. The power of 10 is the number of places the decimal point was moved, positive if moved to the left, negative if moved to the right.

Real numbers are stored in the computer using a similar principal to standard form. Instead of using a power of 10 however, they are stored using a power of 2. The decimal part of the number is known as the mantissa, and the power of 2 to which it is raised is known as the exponent. For simplicity in the examples given will use 16 bits. In practice real numbers are stored using a minimum of 32 bits. The greater the number of bits for the mantissa, the greater the precision that the number can be stored. The greater the number of bits for the exponent the greater the range of the number.

Our 16 bit numbers will use 10 bits for the mantissa and 6 bits for the exponent.

Converting From Denary To Floating Point Binary

6.5

Convert the absolute value of the decimal number to fixed point binary.110.1
Move the binary point so that the first digit is non-zero..1101 (3 places to the left)
Replace the binary point with a zero, pad out the right hand side of the number with 0s to make the number 10 digits.0110100000
If the original number was negative, convert it to two's complement form. This makes the mantissa.0110100000
Convert the number of places the binary point moved into a 6 bit binary number.000011
If the point was moved to the right, convert the number to two's complement form. This makes the exponent.000011
The whole floating point number is the mantissa followed by the exponent.0110100000000011

0.125

Convert the absolute value of the decimal number to fixed point binary.0.001
Move the binary point so that the first digit is non-zero..1 (moved 2 places to the right)
Replace the binary point with a zero, pad out the right hand side of the number with 0s to make the number 10 digits.0100000000
If the original number was negative, convert it to two's complement form. This makes the mantissa.0100000000
Convert the number of places the binary point moved into a 6 bit binary number.000010
If the point was moved to the right, convert the number to two's complement form. This makes the exponent.111110
The whole floating point number is the mantissa followed by the exponent.0100000000111110

-42.75

Convert the absolute value of the decimal number to fixed point binary.101010.11
Move the binary point so that the first digit is non-zero..10101011 (moved 6 places to the left)
Replace the binary point with a zero, pad out the right hand side of the number with 0s to make the number 10 digits.0101010110
If the original number was negative, convert it to two's complement form. This makes the mantissa.1010101010
Convert the number of places the binary point moved into a 6 bit binary number.000110
If the point was moved to the right, convert the number to two's complement form. This makes the exponent.000110
The whole floating point number is the mantissa followed by the exponent.1010101010000110

-0.1875

Convert the absolute value of the decimal number to fixed point binary.0.0011
Move the binary point so that the first digit is non-zero..11 (moved 2 places to the right)
Replace the binary point with a zero, pad out the right hand side of the number with 0s to make the number 10 digits.0110000000
If the original number was negative, convert it to two's complement form. This makes the mantissa.1010000000
Convert the number of places the binary point moved into a 6 bit binary number.000010
If the point was moved to the right, convert the number to two's complement form. This makes the exponent.111110
The whole floating point number is the mantissa followed by the exponent.1010000000111110

Converting From Floating Point Binary To Denary

0100010000000011

Convert the exponent of the number to denary. Perform two's complement if the exponent starts with a 1.000011 = 3
If the mantissa was negative, perform two's complement to convert to a positive number.0100010000
Replace the first zero with a binary point..100010000
Move the binary point the number of places indicated by the exponent (to the right if the exponent is positive, to the left if negative).100.010000
Convert the fixed point binary number to denary. Remember to add the negative sign if the mantissa was negative.4.25

0111000000111110

Convert the exponent of the number to denary. Perform two's complement if the exponent starts with a 1.111110 = -2
If the mantissa was negative, perform two's complement to convert to a positive number.0111000000
Replace the first zero with a binary point..111000000
Move the binary point the number of places indicated by the exponent (to the right if the exponent is positive, to the left if negative)..00111000000
Convert the fixed point binary number to denary. Remember to add the negative sign if the mantissa was negative.0.21875

1001111110000111

Convert the exponent of the number to denary. Perform two's complement if the exponent starts with a 1.000111 = 7
If the mantissa was negative, perform two's complement to convert to a positive number.0110000010
Replace the first zero with a binary point..110000010
Move the binary point the number of places indicated by the exponent (to the right if the exponent is positive, to the left if negative).1100000.1
Convert the fixed point binary number to denary. Remember to add the negative sign if the mantissa was negative.-96.5

Tips For Floating Point Conversions

The two methods described above need to be learned. When doing exercises, you need to follow the methods exactly. Long strings of binary digits are difficult to read and mistakes are easy to make. You can check your answers using the binary converter program. Get it by clicking EXECUTABLE - 44KB or ZIPPED SOURCE CODE - 7.5KB. Use the program to check that you are performing the calculations correctly, not to avoid doing the maths yourself.