2

Today I want to ask question about floating point value issues, but found 2 similar tags (I think) : and .

is remapped to , so I guess refers to all data types and is restricted to float only, is that right? And, should also be remapped to ?

1
  • 6
    Thinking that precision and accuracy are synonyms get a lot of programmers into trouble. Making the tags synonymous would be a very drastic mistake. Bad idea. Commented Nov 11, 2015 at 9:29

2 Answers 2

1

These are different, but you could probably put an argument that the tag wikis need help.

precision refers to the range of numbers that can be represented - often quoted in terms of significant figures (or, when dealing with binary numbers, significant bits). Accuracy is related to numbers that are within that precision but still can't be represented exactly.


For example, an IEEE754 Double has 53 significant bits of mantissa precision (and 11 bits of exponent precision), giving (according to Wikipedia) 15-17 significant decimal figures. But the number one tenth (decimal 0.1), which with one significant decimal figure is well within that precision, can't be represented exactly as an IEEE754 Double.


You could argue that they are technically the same thing (0.1 requires infinitely many significant bits when stored in binary, and not enough bits is a precision thing), but they cause different types of problems that have different types of solutions.

Although various programming languages apply some magic to display the value 0.1 instead of 0.1000000000000000055511151231257827021181583404541015625, accuracy problems can cause cumulative errors in calculations:

>>> a = sum([0.1]*10)
>>> b = 0.1*10
>>> a
0.9999999999999999
>>> b
1.0
>>> a == b
False

The solution to these is to either:

  • Rearrange your arithmetic to do less, bigger calculations (such as one multiplication instead of 10 additions), or
  • Use a type that can accurately represent the values you care about (eg, a decimal float type or a fraction/rational type)

Precision problems will cause problems like overflow or underflow (overflowing IEEE754 operations tend to return ±infinity, but other numeric types might have different behavior like 'wrapping around'):

>>> m = sys.float_info.max
>>> m
1.7976931348623157e+308
>>> 2*m
inf

The solution to these is to use a wider precision type, or even an unlimited precision type (like Python's int or Java's BigInteger, or extended precision floats like C's long double).

1

There is very much a difference between precision and accuracy, as one of my answers on SO points out:

What is the difference between 'precision' and 'accuracy'?

Although I'm having trouble envisaging where a developer would actually find in useful to discuss accuracy except in the context of precision, I don't think we should conflate the two since, after all, my inability to envisage such a situation is irrelevant as I'm not omniscient. Yet :-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .