close Warning: Can't synchronize with repository "(default)" (/project/cmucl/public_html/git/cmucl.git does not appear to be a Git repository.). Look in the Trac log for more information.

Opened 12 years ago

Closed 10 years ago

#1 closed defect (fixed)

prin1 and ~E produce different outputs.

Reported by: anonymous Owned by: rtoy
Priority: minor Milestone:
Component: Core Version: 19c
Keywords: printing Cc:

Description (last modified by rtoy)

(let ((x (random 1d-3)))
  (values (prin1-to-string x)
          (format nil "~E" x)))

will produce different significant digits. I think the problem is in ~E which calls lisp::scale-exponent to scale the number between 0.1 and 1. I think we could just call flonum-to-digits which will give us the digits and the exponent. We can massage that into the desired digits and exponent as in scale-exponent, but we won't have the round-off problem.

Maybe.

Change History (4)

comment:1 Changed 12 years ago by rtoy

  • Owner changed from somebody to rtoy
  • Status changed from new to assigned

comment:2 Changed 12 years ago by rtoy

  • Version set to 19c

comment:3 Changed 11 years ago by rtoy

  • Description modified (diff)

comment:4 Changed 10 years ago by rtoy

  • Resolution set to fixed
  • Status changed from assigned to closed

One particular example is

(format nil "~E" 1.234567890123456789d4)
"1.2345678901234565d+0"

The right answer is

"1.2345678901234567d+0"

which is what prin1 returns.

This should now be fixed in CVS.

Note: See TracTickets for help on using tickets.