[mercury-users] [Feature request] Printing reasonable floats/printer pred

Ralph Becket rafe at csse.unimelb.edu.au
Mon Feb 12 14:45:11 AEDT 2007

doug.auclair at logicaltypes.com, Sunday, 11 February 2007:
> Dear Ralph, you wrote:
> >I think the solution that would satisfy 99% of users would be to simply
> >trim redundant trailing zeroes from floats unless a specific precision
> >has been specified.
> I must be a 1%er then (I always knew I was 'special'), because this doesn't
> work in my specific (or, more generally, in my general) situation -- when
> the RNG gives me a value (which I then convert into N / RandMax float),
> I only care about one digit of precision, but it has many other (usually
> non-zero) numbers trailing what I care about.
> In the general case, when I'm printing a float, I almost always only care
> about one or two digits of precision, some of the time the other digits
> are zero, but not very often, because when I'm dealing with floats, I more
> often than not have a good deal of noise or randomness "below the radar".
> It's more work than automatic zero truncation, but could user control
> over printing (precision) please be worked in for objects (floats)?

I don't think this is general enough to warrant inclusion in the
standard library.

The obvious solution is for you to write your own printer or simply not
generate the "noise" digits at all.

A more general solution, which I'm working on (slowly), is to add
general purpose user-defined pretty-printing support.

-- Ralph
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au

More information about the users mailing list