[issue31435] Addition giving incorrect result in certain circumstances

2017-09-12 Thread R. David Murray

R. David Murray added the comment:

https://docs.python.org/3/tutorial/floatingpoint.html

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31435] Addition giving incorrect result in certain circumstances

2017-09-12 Thread Stefan Krah

Stefan Krah added the comment:

Pythons has binary floating point, which does not give the same
results as a pocket calculator.

You can see the differences by using the decimal module:


# These are the binary floats in exact decimal representation.
>>> Decimal(7.95)
Decimal('7.95017763568394002504646778106689453125')
>>> Decimal(8.95)
Decimal('8.949289457264239899814128875732421875')


# This is exact decimal arithmetic.
>>> Decimal("8.95") + Decimal("0.95")
Decimal('9.90')

--
nosy: +skrah
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31435] Addition giving incorrect result in certain circumstances

2017-09-12 Thread Aodhán Collins

New submission from Aodhán Collins:

Basic addition is dropping a tiny fraction when adding together certain 
numbers. We have discovered that when adding together the numbers 8.95 and 0.95 
we get an incorrect answer, that is off by a tiny fraction. This doesn't occur 
when adding 7.95 and 0.95 but occurs for 8.95 and above. We have attached a 
file showing our calculations failing on Python 2.7 (on both a Mac and Linux 
system) and 3.5 (on a Linux system).

--
components: Interpreter Core
files: pythonbug.txt
messages: 301991
nosy: Aodhán Collins
priority: normal
severity: normal
status: open
title: Addition giving incorrect result in certain circumstances
type: behavior
versions: Python 3.5
Added file: https://bugs.python.org/file47136/pythonbug.txt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com