--- /usr/local/axiom/int/algebra/DFLOAT.spad 2006-02-11 16:02:12.350650696 +0100 +++ DFLOAT.spad 2005-07-24 18:23:33.051285856 +0200 @@ -62,6 +62,7 @@ ++ Gamma(x) is the Euler Gamma function. Beta : (%,%) -> % ++ Beta(x,y) is \spad{Gamma(x) * Gamma(y)/Gamma(x+y)}. + doubleFloatFormat : String -> String rationalApproximation: (%, NonNegativeInteger) -> Fraction Integer ++ rationalApproximation(f, n) computes a rational approximation ++ r to f with relative error \spad{< 10**(-n)}. @@ -71,10 +72,17 @@ ++ (that is, \spad{|(r-f)/f| < b**(-n)}). == add + format: String := "~G" MER ==> Record(MANTISSA:Integer,EXPONENT:Integer) manexp: % -> MER + doubleFloatFormat(s:String): String == + ss: String := format + format := s + ss + + OMwrite(x: %): String == s: String := "" sp := OM_-STRINGTOSTRINGPTR(s)$Lisp @@ -132,7 +140,7 @@ -- rational approximation to e accurate to 23 digits exp1() == FLOAT(534625820200,MOST_-POSITIVE_-LONG_-FLOAT$Lisp)$Lisp / FLOAT(196677847971,MOST_-POSITIVE_-LONG_-FLOAT$Lisp)$Lisp pi() == PI$Lisp - coerce(x:%):OutputForm == outputForm(x pretend DoubleFloat) + coerce(x:%):OutputForm == outputForm(FORMAT(NIL$Lisp,format,x)$Lisp pretend DoubleFloat) convert(x:%):InputForm == convert(x pretend DoubleFloat)$InputForm x < y == (x