[GRASS-dev] Re: output precision of r.info and r.univar

Glynn Clements glynn at gclements.plus.com
Wed Oct 8 08:45:57 EDT 2008


Markus Neteler wrote:

> I just found Glynn's comment:
> 
> On Wed, Oct 8, 2008 at 9:36 AM, Glynn Clements <glynn at gclements.plus.com> wrote:
> ...
> > Too much precision is ugly. Too little precision makes it impossible
> > to use small values. A general-purpose conversion routine such as this
> > needs to handle the full range of floating-point values, which
> > basically means %.15g.
> 
> So should I go for that?

Yes.

%f is only useful in situations where you know the range and precision
of the values involved. E.g. for coordinates, you know that they won't
exceed the circumference of the earth, and that the precision doesn't
need to be better than a millimetre, if that.

But cell values can be arbitrary quantities; 1e20 and 1e-20 are both
entirely plausible. And statistical aggregates of those values can
have an even greater range (e.g. sum can be much larger than an
individual value, stddev can be much smaller, and variance can be
massively larger or smaller due to the squaring).

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list