background preloader

IEEE754

Facebook Twitter

Что нужно знать про арифметику с плавающей запятой / C++ В далекие времена, для IT-индустрии это 70-е годы прошлого века, ученые-математики (так раньше назывались программисты) сражались как Дон-Кихоты в неравном бою с компьютерами, которые тогда были размером с маленькие ветряные мельницы.

Что нужно знать про арифметику с плавающей запятой / C++

Задачи ставились серьезные: поиск вражеских подлодок в океане по снимкам с орбиты, расчет баллистики ракет дальнего действия, и прочее. Для их решения компьютер должен оперировать действительными числами, которых, как известно, континуум, тогда как память конечна. Поэтому приходится отображать этот континуум на конечное множество нулей и единиц.

В поисках компромисса между скоростью, размером и точностью представления ученые предложили числа с плавающей запятой (или плавающей точкой, если по-буржуйски). Арифметика с плавающей запятой почему-то считается экзотической областью компьютерных наук, учитывая, что соответствующие типы данных присутствуют в каждом языке программирования. 1. Математически это записывается так: (-1)s × M × 2E (-1)s × 1.M × 2E. 2. 3. IEEE 754-2008. The IEEE Standard for Floating-Point Arithmetic (IEEE 754) is a technical standard for floating-point computation established in 1985 by the Institute of Electrical and Electronics Engineers (IEEE).

IEEE 754-2008

Many hardware floating point units use the IEEE 754 standard. The current version, IEEE 754-2008 published in August 2008, includes nearly all of the original IEEE 754-1985 standard and the IEEE Standard for Radix-Independent Floating-Point Arithmetic (IEEE 854-1987). The international standard ISO/IEC/IEEE 60559:2011 (with identical content to IEEE 754) has been approved for adoption through JTC1/SC 25 under the ISO/IEEE PSDO Agreement[1] and published.[2] The standard defines The standard also includes extensive recommendations for advanced exception handling, additional operations (such as trigonometric functions), expression evaluation, and for achieving reproducible results.

Formats[edit] An IEEE 754 format is a "set of representations of numerical values and symbols". A format comprises: Numeric precision in Microsoft Excel. As with other spreadsheets, Microsoft Excel works only to limited accuracy because it retains only a certain number of figures to describe numbers (it has limited precision).

Numeric precision in Microsoft Excel

Excel nominally works with 8-byte numbers by default, a modified 1985 version of the IEEE 754 specification[1] (Besides numbers, Excel uses a few other data types.[2]) Although Excel can display 30 decimal points, its precision for a specified number is confined to 15 significant figures, and calculations may have an accuracy that is even less due to three issues: round off,[3] truncation, and binary storage. Accuracy and binary storage[edit] Excel maintains 15 figures in its numbers, but they are not always accurate: the bottom line should be the same as the top line. Of course, 1 + x − 1 = x. The discrepancy indicates the error. In the top figure the fraction 1/9000 in Excel is displayed. The inaccuracy in Excel calculations is more complicated than errors due to a precision of 15 significant figures.

Both cells and. How to correct rounding errors in floating-point arithmetic. Many combinations of arithmetic operations on floating-point numbers in Microsoft Excel and Microsoft Works may produce results that appear to be incorrect by very small amounts.

How to correct rounding errors in floating-point arithmetic

For example, the equation may be evaluated to the quantity (-2.78E-17), or -0.0000000000000000278 instead of 0. This behavior is not a problem in or a limitation of Excel or Works; this behavior occurs because the Institute of Electrical and Electronics Engineers (IEEE) 754 floating-point standard requires that numbers be stored in binary format. Method 1 To minimize any effects of floating point arithmetic storage inaccuracy, use the Round() function to round numbers to the number of decimal places that is required by your calculation.

Method 2 You can frequently prevent floating point rounding errors from affecting your work by using the Precision as displayed option. Note Use of the Precision as Displayed option can have cumulative calculation effects that can make your data increasingly inaccurate over time. Floating-point arithmetic may give inaccurate results in Excel. This article discusses how Microsoft Excel stores and calculates floating-point numbers.

Floating-point arithmetic may give inaccurate results in Excel

This may affect the results of some numbers or formulas due to rounding and/or data truncation. Overview Microsoft Excel was designed around the IEEE 754 specification with respect to storing and calculating floating-point numbers. IEEE is the Institute of Electrical and Electronics Engineers, an international body that, among other things, determines standards for computer software and hardware. The 754 specification is a very widely adopted specification that describes how floating-point numbers should be stored in a binary computer. When storing numbers, a corresponding binary number can represent every number or fractional number. 0001100110011100110011 (and so on) and can be infinitely repeated. However, there are some limitations of the IEEE 754 specification which fall into three general categories: