Floating Point: Computer format for representing rational numbers

Real numbers in binary have to be stored in a special way in a computer.

Computers represent numbers as binary integers (whole numbers that are powers of two), so there is no direct way for them to represent non-integer numbers like decimals as there is no radix point. One way computers bypass this problem is floating-point representation, with "floating" referring to how the radix point can move higher or lower when multiplied by an exponent (power).

Overview

In mathematics and science, very large and very small numbers are often made simpler and multiplied to a power of ten to make them easier to understand. For example, it can be much easier to read 1.2 trillion as Floating Point: Overview, Example, Related pages  than 1,200,000,000,000. This can also be used with negative powers of ten to make small numbers, meaning you can represent 0.000001 as Floating Point: Overview, Example, Related pages . This process is called scientific notation.

Since computers are limited to integers and binary, this means they cannot easily represent fractional decimal numbers. In order to represent fractional numbers, computers use three sets of binary numbers to make a scientific notation representation. They are: the signed bit, which determines if the number is positive (0) or negative (1); the significand, which is an integer (whole) version of the number; and the exponent, which is the power you multiply the base by.

Significand

The significand is found by taking your number and moving the radix point until there is no fractional part, making it into an integer. In decimal this is making 1.45 into 145 by moving the point right 2 steps, and in binary this would be making 1101.0111 (13.4375) into 1101 0111 (215) by moving the point right 4 steps; in both cases these numbers aren't related to one another outside using the same digits in a similar ordering.

Similarly to how scientific notation makes the significand as basic as possible, the aim in floating point numbers is to make it an integer so it can be represented in bytes and used in calculations.

Exponent

The exponent is the number of digits the radix point has moved past: if it moves left then the exponent is negative, but if it moves right then it is positive. As above, making 1.45 into 145 requires you to multiply by 100, so the exponent is 2 as Floating Point: Overview, Example, Related pages . Equally, turning 1101.0111 (13.4375) into 1101 0111 (215) requires you to move the radix point four columns to the right, so the exponent is 4; this can be verified in decimal as Floating Point: Overview, Example, Related pages .

Since the process is inverted to most cases of scientific notation, as it involves making a fraction into an integer rather than turning a large integer into a fraction, exponents are generally negative to move the decimal place to the left; in decimal this would be turning your integer 145 back into the fractional number 1.45 by multiplying it by Floating Point: Overview, Example, Related pages . Instead of using an signed leftmost bit the exponent is instead biased, giving 32-bit float exponents a range of Floating Point: Overview, Example, Related pages  to Floating Point: Overview, Example, Related pages . The output value of the biased exponent can be found by adding 127 to it:

Floating Point: Overview, Example, Related pages 

Floating Point: Overview, Example, Related pages 

Floating Point: Overview, Example, Related pages 

Example

Decimal to Bicimal

Let's assume, for example, we want to represent the decimal number 37.40625 to its binary counterpoint: a bicimal (or binary decimal/fraction). First, we need to take our decimal number, which is in powers of 10, and convert it to binary, which is in powers of 2. One way to do this is to subtract the largest power of two possible until you reach zero:

Floating Point: Overview, Example, Related pages 

Floating Point: Overview, Example, Related pages 

Floating Point: Overview, Example, Related pages 

Floating Point: Overview, Example, Related pages 

Floating Point: Overview, Example, Related pages 

Floating Point: Overview, Example, Related pages 

Using the powers of two above, we can represent our decimal number Floating Point: Overview, Example, Related pages  as follows:

Power: Floating Point: Overview, Example, Related pages  Floating Point: Overview, Example, Related pages  Floating Point: Overview, Example, Related pages  Floating Point: Overview, Example, Related pages  Floating Point: Overview, Example, Related pages  Floating Point: Overview, Example, Related pages  Floating Point: Overview, Example, Related pages  Floating Point: Overview, Example, Related pages  Floating Point: Overview, Example, Related pages  Floating Point: Overview, Example, Related pages  Floating Point: Overview, Example, Related pages 
Value: 1 0 0 1 0 1 0 1 1 0 1

Bicimal to Float

We have validated that our decimal number Floating Point: Overview, Example, Related pages  is represented in binary as Floating Point: Overview, Example, Related pages . However, the issue with computers is that they represent numbers as integer powers of two using bits, which makes fractional and negative numbers complicated. In accordance with IEEE-754, the way this is commonly done with a computer is to create a 32-bit floating point number that consists of three parts:

  • The sign, 1 bit to determine if our number is positive or negative.
  • The exponent, 8 bits. We add the value 127 to it to account for the sign bit which is the most significant bit.
  • The significand, which is our binary number without a bicimal point spread across 23 bits.

Since we need to move our bicimal point 5 places to make Floating Point: Overview, Example, Related pages  into the significand Floating Point: Overview, Example, Related pages  our exponent is Floating Point: Overview, Example, Related pages . By using a 32-bit float we can represent 37.40625 like this:

Type: ±
Exponent Significand
Value: 0 1 0 0 0 0 1 0 0 0 0 1 0 1 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
Meaning: + Floating Point: Overview, Example, Related pages  Floating Point: Overview, Example, Related pages 

Tags:

Floating Point OverviewFloating Point ExampleFloating Point Related pagesFloating PointBinaryComputerExponentiationIntegersRadix pointReal number

🔥 Trending searches on Wiki Simple English:

2024 Formula One World ChampionshipMalala YousafzaiSquash (plant)MexicoSign languageChurch (building)Mikhail TalCo-educationMarie Thérèse Louise of Savoy, Princesse de LamballePotatoList of cities in ItalyLogic (rapper)Hello Kitty murder casePlumSexual intercourse2 Girls 1 CupSolar SystemBTSBrickJacqueline Kennedy Onassis22nd centuryNanga ParbatLeetOpiumEmilia ClarkeWatergate scandalManhattanAK-47Computer programAlkene4DBekabooLionRRR (movie)Pawn shopP-type semiconductorApple Inc.List of hamburger restaurantsCultureEd LauterBear (gay slang)Hatful of HollowMiddle schoolThe Human Centipede 2 (Full Sequence)JalapeñoList of cities in the United KingdomLight bulbNelson MandelaAuguste CharloisHarry StylesRaccoonBatman BeginsHistory of ChristianityPostal codes in GermanyUnit of measurementKeanu ReevesLahoreTrinidad and TobagoSoviet–Afghan WarBrihadeshwara TempleMain PageNeil ArmstrongBinary numberClassification of Indian citiesTansenElizabeth IIVenusTV.comMulberryGrameen BankSouthern United StatesTheta2019 UEFA Champions League FinalThe Picture of Dorian GrayDongguanQuickie (sex)Trans man🡆 More