On Sun, 2023-04-16 at 10:50 -0700, Nils Bruin wrote:
>  
> That's a facetious example that sticks to values that can be exactly 
> represented in binary floats. These identities don't hold generally:
> 
> sage: 49*(1.0/49) == ZZ(1)
> False
> 
> (it depends on your working precision if rounding makes this come out as an 
> exact match or not, but at 53 bits this one fails to give equality. In all 
> cases, there are values where this breaks; necessarily)

I didn't make that example up to make a point, it's a real problem I
reported ~15 years ago in undergrad. And the fact that it's an easy
case only makes it *more* surprising that sage doesn't handle it.

We don't need a perfect solution to get it right most of the time. How
often does someone type 1/49 = 0.02040816326530612... into a matrix?
But Sage actually knows that number too:

  $ sage -python
  Python 3.11.2 (main, Mar 16 2023, 15:12:59) [GCC 12.2.1 20230121] onĀ 
  linux
  Type "help", "copyright", "credits" or "license" for moreĀ 
  information.
  >>> from sage.all import *
  >>> QQ(0.02040816326530612)
  1/49


-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/b2e128ee0d91cc0f8f05fd160e07d23da1f0714f.camel%40orlitzky.com.

Reply via email to