From: Steve Haflich

Subject: Re: Changing printing format for float

Date: 2000-7-7 13:17

   From: Kai Yue <ispchannel.com at kai>
   
     I wonder if there is a way in ACL to control the number of
   digits after the decimal point in printing floating point numbers using
   PRINT. 

Changing PRINT probably isn't the right thing to think about, since
essentially no other functions call PRINT, and if you somehow did
affect the behavior of (PRINT 1.0) that wuold probably have no effect
on (PRINT '(A 1.0)).

There are two ways to control the behavior of the printer in ANSI CL:

- You can write a specialed method on PRINT-OBJECT.  See the ANS.
Unfortunately, such a method must be specialized on _your_ class and
cannot be specialized _only_ on system classes.  Since a FLOAT is a
system class, you'd be required to specialize the behavior also on the
stream argument and create your own specialized class of stream.  This
seems needlessly indirect, and may have performance implications
besides.

- The other way, provided you are willing to use the pretty printer
(i.e. that *PRINT-PRETTY* is true), is to create your own copy of the
pprint-dispatch table and write a dispatch for FLOAT that simply uses
FORMAT to print with the desired format.  This is fairly easy to do --
see the ANS re pretty print dispatch tables and SET-PPRINT-DISPATCH.