On Saturday, May 26, 2012 9:45:39 PM UTC+2, Snark wrote:
>
> Le dimanche 20 mai, Julien Puydt a écrit: 
> > sage -t  --long -force_lib 
> > devel/sage/sage/interfaces/maxima_abstract.py 
> > ********************************************************************** 
> > File 
> > 
> "/home/jpuydt/sage-5.0/devel/sage-main/sage/interfaces/maxima_abstract.py", 
> > line 1595: sage: float(maxima("1.7e+17")) Expected: 1.7e+17 
> > Got: 
> >     1.6999999999999997e+17 
> > ********************************************************************** 
> > 
> > This is an ECL bug, reported upstream : 
> > 
> http://sourceforge.net/tracker/?func=detail&atid=398053&aid=3495303&group_id=30035
>  
>
> Sigh... upstream tested and found it wasn't their fault, so I guess 
> there's something else somewhere :-/ 
>

Actually that number above is different from the one in the bug report, 
which had been reduced to a call to FORMAT: (format t "~21e" 1.7e+17) 
Perhaps Maxima is using some _other_ instruction for printing floating 
point numbers? It also matters whether the floating point number is double 
float or not.

It also matters what maxima() returns (a string?) and how python converts 
it to floating point number: ECL uses a method to match printed 
representation and floating point numbers which is NOT the C library, for 
this has proven to be buggy (to say the least). Instead ECL uses a routine 
found in SBCL which is from a paper (by Steele 
http://grouper.ieee.org/groups/754/email/pdfq3pavhBfih.pdf) but this 
printer is not always active: if you fix the number of decimal places, the 
printer need not produce the most accurate representation.

For instance, if you type 1.7d+17 in the toplevel of a Common Lisp 
implementation, the lisp will output a number 1.7d+17 However, if you use 
(format t "~21v" 1.7d+17) you do not get this.

Ok, to make a long story short, the situation might be:

* Python relies on the C library to reconstruct a floating point number 
representation which is accurate, but does not recover the right number (C 
library does the wrong rounding).
* Maxima is using some other function for output of floating point numbers 
and the bug report was thus inaccurate.

Juanjo

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to