Definition of Floating Point DataDate: 07/02/2001 at 19:53:01 From: Judy Strasbaugh Subject: Definition of 'floating point' data? What are 'floating point data'? How do they differ from an integer? What are some examples? I looked up both 'floating point' and 'fixed point' in Webster's Dictionary, but the definitions do not provide examples that are meaningful to me. Date: 07/02/2001 at 23:11:31 From: Doctor Peterson Subject: Re: Definition of 'floating point' data? Hi, Judy. The Dr. Math archives include these answers: Floating-Point Binary Fractions http://mathforum.org/dr.math/problems/mairaj.7.19.99.html Fixed Point and Floating Point Numbers http://mathforum.org/dr.math/problems/huband.5.19.00.html I'll try to give a more basic explanation that is as clear as possible. What you will see in a computer program (as opposed to what the computer itself sees) will look like this (an example in the C language): int a; float b; a = 12; b = 12.0; I've told the computer that "a" is an integer and "b" is a floating point number. (Some languages would call the latter "real," which is a bit of a misnomer.) This tells the computer (actually, the compiler that turns my program into something the computer can read) to find a place to store the variable "a" as an integer, and a place to store "b" using floating point format. Then I told it to store the integer 12 in a, and the decimal number 12.0 in b. As a user, all you have to know is that an integer can hold a (positive or negative) whole number; a floating point variable can store a decimal value. Internally, the computer will store the following binary number in a: 00000000 00000000 00000000 00001100 This is 12 in base 2; it means 1*2^3 + 1*2^4. (I'm using "^" to indicate an exponent, and "*" for multiplication.) In b, it will store 01000001 01000000 00000000 00000000 This encodes the value +1.5 * 2^3 = 1.5 * 8 = 12 What it's done is to put 12 in the binary equivalent of scientific notation, by dividing 12 by 2 until the quotient is between 1 and 2, and then writing it as the product of this quotient, 1.5 (called the mantissa or significand), and a power of 2, namely 2 cubed, or 8. It's hard to see either 1.5 or 3 in there, but the first answer I pointed out in our archives will explain how it's encoded if you want to know. The important thing is just that it is encoded in a way that the computer can work with; otherwise, programs would be restricted to integers. I used the same number in this example; if I had used 12.3, I would have been able to store that (correctly) only in floating point form. In an integer variable, only "12" would have been stored. Note, however, that 12 is valid floating point data; the difference is in how it is stored. When data are stored in integer form, they use space as efficiently as possible; the range of values that can be stored in 32 bits (the usual size currently) is from -2,147,483,648 to +2,147,483,647. The value is stored exactly, allowing up to 10 digits of precision (decimal). The problem, of course, is that only whole numbers can be used. When data are stored in floating point format, there is somewhat less precision, because some bits are used to store the exponent, leaving fewer to store the actual value of the mantissa. However, the range of numbers that can be stored is much greater: from -3.4028E+38 to 3.4028E+38, either positive or negative, and numbers as small as 1.1754E-38 can be stored with just as much precision. It is not exact, however, but holds only about 7 significant digits (decimal). There are other integer and floating point formats in use, such as 64 bits; the same principles still apply, but with different numbers. - Doctor Peterson, The Math Forum http://mathforum.org/dr.math/ Date: 07/03/2001 at 12:37:37 From: Strasbaugh, Judith Subject: Re: Definition of 'floating point' data? Thanks so much. You've written the explanation so well, I actually understand it! Judy Strasbaugh |
Search the Dr. Math Library: |
[Privacy Policy] [Terms of Use]
Ask Dr. Math^{TM}
© 1994-2013 The Math Forum
http://mathforum.org/dr.math/