[issue39086] Division "/" error on Long Integers

2019-12-18 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Looking at your first example, you calculate:

   >>> 63945173192649609/13
   4918859476357662.0


which is correct when using floats (64-bit C doubles). 64 bits are not enough 
to be any more precise, and you would get the same result in C or any other 
language using the same precision.

Using Decimal with the default precision, you could get:

>>> decimal.Decimal(63945173192649609)/13
Decimal('4918859476357662.230769230769')

but the exact result is 4918859476357662.[230769] where the decimal part inside 
the square brackets [...] repeats forever.

So within the limitations of the C 64-bit double floating point format, the 
calculation is correct and there is no bug here.

Please see

https://docs.python.org/3/faq/design.html#why-are-floating-point-calculations-so-inaccurate

for more information.

--
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



[issue39086] Division "/" error on Long Integers

2019-12-18 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Please don't post unnecessary screen shots of text. They are impossible for us 
to copy your code, we have to re-type it from scratch, and retyping 17-digit 
numbers is prone to typos. Screenshots make it difficult or impossible for the 
blind and visually impaired, who may be using screen readers, to contribute. 
Please copy and paste the actual text of your code, the results and the 
expected values.

You say you tested the values with a calculator, but which calculator and how 
do you know it is accurate?

I can't work out the connection between the competition and your calculations. 
Clicking on the "Problem" link takes me to a problem about dice.

--
nosy: +steven.daprano

___
Python tracker 

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



[issue39086] Division "/" error on Long Integers

2019-12-18 Thread Mradul Tiwari


New submission from Mradul Tiwari :

I'm a Competitive programmer and got Wrong Answer because of this division 
issue, which I figured out post Contest. Please See the attached screenshot.

The "/" operator gives float division but for long integers, it's giving 
integer answer. I've tested it on several values but the result doesn't matched 
with expected answers. I've also googled a lot about this but can't get the 
explanation.

Please go to link "https://codeforces.com/contest/1266/submission/67106918;
and see the actual arise of problem on SEVERAL VALUES, in detail section, in 
TestCase 3 which have very large integers.

In my code at that link, the error arises inside the function get(x) at line 
"c=(x-i)/14"

--
assignee: docs@python
components: Documentation
files: Tested values.png
messages: 358622
nosy: Mradul, docs@python
priority: normal
severity: normal
status: open
title: Division "/" error on Long Integers
type: behavior
versions: Python 3.7
Added file: https://bugs.python.org/file48787/Tested values.png

___
Python tracker 

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