bug in rational arithmetic ?



Richard Fateman wrote:
> bfloat(2.1d0) should be
> 
> 2.100000000000000088817841970012523233890533447265625b0
> 

FWIW, here is a replacement for floattofp:

(defun floattofp (x)
   (unless $float2bf
     (mtell "Warning:  Float to bigfloat conversion of ~S~%" x))
   (multiple-value-bind (frac exp sign)
       (integer-decode-float x)
     ;; Scale frac to the desired number of bits, and adjust the
     ;; exponent accordingly.
     (let ((scale (- fpprec (integer-length frac))))
       (list (ash (* sign frac) scale)
	    (+ fpprec (- exp scale))))))

Then, bfloat(2.1) is 
2.100000000000000088817841970012523233890533447265625b0.

The testsuite runs fine, except for prob 6 in rtest_dot:  1.1 . 1.1b0 
was expected to return 1.21b0, but we actually get 1.2100000000000001b0. 
  I think the latter is the right answer.

Ray