From: Samuele P. <ped...@us...> - 2003-08-05 11:22:13
|
Update of /cvsroot/jython/jython/org/python/modules In directory sc8-pr-cvs1:/tmp/cvs-serv20282/org/python/modules Modified Files: math.java Log Message: implemented coversion to double+scale, reimplemented true division for longs using it (like CPython) same for math.log/10 . test_long now passes, test_long_future also partially ( only partially because of buggy unrelated future flags inheritance - to fix). Index: math.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/math.java,v retrieving revision 2.5 retrieving revision 2.6 diff -C2 -d -r2.5 -r2.6 *** math.java 6 Nov 2002 08:14:06 -0000 2.5 --- math.java 5 Aug 2003 11:22:08 -0000 2.6 *************** *** 56,60 **** } ! public static double log(double v) { return check(Math.log(v)); } --- 56,70 ---- } ! public static double log(PyObject v) { ! if (v instanceof PyLong) { ! int e[] = new int[1]; ! double x = ((PyLong)v).scaledDoubleValue(e); ! if (x <= 0.0) throw Py.ValueError("math domain error"); ! return log(x) + (e[0]*8.0)*log(2.0); ! } ! return log(v.__float__().getValue()); ! } ! ! private static double log(double v) { return check(Math.log(v)); } *************** *** 86,96 **** public static double log10(PyObject v) { if (v instanceof PyLong) { ! // XXX: This shouldn't fail for really large longs. ! return log10(v.__float__().getValue()); } return log10(v.__float__().getValue()); } ! public static double log10(double v) { return check(ExtraMath.log10(v)); } --- 96,108 ---- public static double log10(PyObject v) { if (v instanceof PyLong) { ! int e[] = new int[1]; ! double x = ((PyLong)v).scaledDoubleValue(e); ! if (x <= 0.0) throw Py.ValueError("math domain error"); ! return log10(x) + (e[0]*8.0)*log10(2.0); } return log10(v.__float__().getValue()); } ! private static double log10(double v) { return check(ExtraMath.log10(v)); } |