On Tue, Sep 23, 2008 at 08:47:15PM -0700, chromatic wrote:
> On Thursday 18 September 2008 06:13:30 Patrick R. Michaud (via RT) wrote:
> > When generating PIR output (e.g., from the compiler tools), we
> > often need to convert a Float value into an equivalent representation
> > for PIR.  Unfortunately, all of the mechanisms I've looked at for
> > doing this lose a lot of precision, which really isn't acceptable.
> 
> How about 15 digits of precision?  The attached patch (which requires a 
> reconfigure) does so.  It also drops trailing zeroes, which may or may not be 
> what you want.  It's much more precise though:
> 
>       set_p_s  : 2.71828182845905
>       get_repr : 2.718281828459045
>       printf %g: 2.718282

The patch works very well -- I even tried it with very large
(1.234e+34) and very small (1.234e-34) positive numbers and always
got back a reasonable string that preserved the level of precision
I was looking for.  Dropping the trailing zeroes is fine (and preferred).

+1 in favor of applying this patch (and updating any tests to match) --
this will _really_ improve things for PCT and Rakudo.  Thanks!

Pm

Reply via email to