>>> 9999999999999999.0 == 10000000000000000.0
True
>>> from decimal import Decimal as D
>>> D(9999999999999999.0)
Decimal('10000000000000000')
"It's a simple question" I find it very much not simple question; indeed I'm not sure what is the expected "right answer" here?9999999999999999.0 – 9999999999999998.0
21–30 of 83 posts
Re: 9999999999999999.0 – 9999999999999998.0
#22Was curious what chatGPT would say: The result of subtracting 9999999999999998.0 from 9999999999999999.0 is 2.0. This result is due to the limitations in the precision of floating-point arithmetic in computers. When dealing with very large numbers, the precision can be lost, leading to such unexpected results. I suppose this must be in its training set.
when I ask about this question it generates and runs Python behind the scenes, thus the incorrect answer.
Re: 9999999999999999.0 – 9999999999999998.0
#23Moral of the story: we all should switch to programming in Perl6.
Re: 9999999999999999.0 – 9999999999999998.0
#24Was curious what chatGPT would say: The result of subtracting 9999999999999998.0 from 9999999999999999.0 is 2.0. This result is due to the limitations in the precision of floating-point arithmetic in computers. When dealing with very large numbers, the precision can be lost, leading to such unexpected results. I suppose this must be in its training set.
Re: 9999999999999999.0 – 9999999999999998.0
#25 postgres=# select 9999999999999999.0 - 9999999999999998.0 as result;
result
--------
1.0Re: 9999999999999999.0 – 9999999999999998.0
#26Was curious what chatGPT would say: The result of subtracting 9999999999999998.0 from 9999999999999999.0 is 2.0. This result is due to the limitations in the precision of floating-point arithmetic in computers. When dealing with very large numbers, the precision can be lost, leading to such unexpected results. I suppose this must be in its training set.
these days it looks like ChatGPT generates and runs code behind the scenes for math questions (it used to be pretty bad at these kinds of math questions. you can click the little "view analysis" button to see the code it's running. when I ask about this question it generates and runs Python behind the scenes, thus the incorrect answer.
Re: 9999999999999999.0 – 9999999999999998.0
#27Was curious what chatGPT would say: The result of subtracting 9999999999999998.0 from 9999999999999999.0 is 2.0. This result is due to the limitations in the precision of floating-point arithmetic in computers. When dealing with very large numbers, the precision can be lost, leading to such unexpected results. I suppose this must be in its training set.
Q: What is the result of subtracting 9999999999999998.0 from 9999999999999999.0
A: The result of subtracting 9999999999999998.0 from 9999999999999999.0 is 1.0. Here is the calculation: 9999999999999999.0−9999999999999998.0=1.0
I also tried a variation and it's still correct, maybe it's using a calculator plugin:
Q: What is the result of 1239995999999999.0 - 1239995999999998.0
A: The result of the subtraction operation 1239995999999999.0−1239995999999998.0 is 1.0
Re: 9999999999999999.0 – 9999999999999998.0
#28Re: 9999999999999999.0 – 9999999999999998.0
#29> That Go uses arbitrary-precision for constant expressions seems dangerous to me. I'm somewhat baffled by this statement. If a Go program compared a constant expression float against a runtime computed float, it could have unexpected results, but comparing floats in general is dangerous. I don't see how this language quirk increases that danger in a meaningful way.
That said, for the negatives it comes with it does come with positives as well and I think that makes it worth it.