<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000099">
    Thanks Markus,<br>
    <br>
    That is certainly a good suggestion. The problem however remains I
    think with the part <br>
    <pre wrap="">round(C / 0.0001)</pre>
    If C/0.0001 > 2^31, i.e., larger then the maximum possible
    integer, there will be an error. <br>
    <br>
    The white spaces, is that for another reason then being clearer?<br>
    <br>
    Cheers,<br>
    <br>
    Paulo<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 05/17/2013 10:57 PM, Markus Metz
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAG+h=FFsOs+ZfRJHpL8763pphmkTcp-2OK-22zcdU6ReGF1oQg@mail.gmail.com"
      type="cite">
      <pre wrap="">On Fri, May 17, 2013 at 5:13 PM, Paulo van Breugel
<a class="moz-txt-link-rfc2396E" href="mailto:p.vanbreugel@gmail.com"><p.vanbreugel@gmail.com></a> wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">Hi Glynn and Rainer

Happy to see this exchange of ideas. It would be great if this could be
implemented. Do you think it is useful I make a feature request on the bug
tracker (with link to this email thread) so the idea doesn't get lost?
</pre>
      </blockquote>
      <pre wrap="">
Instead of

r.mapcalc "A = if(B==0,
(round(C/0.0001)-1175699902)/(3007966667-1175699902) *100.0, 1)"
--overwrite

try

r.mapcalc "A = if(B==0,
(round(C/0.0001)-1175699902.0)/(3007966667.0-1175699902.0) *100.0, 1)"
--overwrite

or better with whitespaces

r.mapcalc "A = if(B == 0, (round(C / 0.0001) - 1175699902.0) /
(3007966667.0 - 1175699902.0) * 100.0, 1)" --overwrite

adding .0 to numbers forces all calculations to be done with  floating
point double precision

Markus M

</pre>
      <blockquote type="cite">
        <pre wrap="">



On Fri, May 17, 2013 at 4:38 PM, Glynn Clements <a class="moz-txt-link-rfc2396E" href="mailto:glynn@gclements.plus.com"><glynn@gclements.plus.com></a>
wrote:
</pre>
        <blockquote type="cite">
          <pre wrap="">

Rainer M. Krug wrote:

</pre>
          <blockquote type="cite">
            <blockquote type="cite">
              <pre wrap="">One option is to modify round() to take a second argument (defaulting
to 1), and have it return the first argument rounded to the nearest
multiple of the second. The return type would be that of the second
argument, i.e. round(x,1) rounds to the nearest integer and returns an
integer, round(x,1.0) rounds to the nearest integer and returns a
float, round(x,1e-3) would round to 3 decimal places (i.e. the nearest
multiple of 0.001), etc.
</pre>
            </blockquote>
            <pre wrap="">
Sounds like a sensible approach without adding to many new
functions. But I would actually split the two, i.e. have two more
arguments, where one specifies the type,
and the other one the number of decimals to round to, i.e.

round(x, 0, "I") would be the default, rounding to whole number and
return an integer
</pre>
          </blockquote>
          <pre wrap="">
That interface isn't possible. r.mapcalc doesn't have a string type,
and there's no way that a function's return type can depend upon the
value of a parameter.

--
Glynn Clements <a class="moz-txt-link-rfc2396E" href="mailto:glynn@gclements.plus.com"><glynn@gclements.plus.com></a>
_______________________________________________
grass-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:grass-dev@lists.osgeo.org">grass-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/grass-dev">http://lists.osgeo.org/mailman/listinfo/grass-dev</a>
</pre>
        </blockquote>
        <pre wrap="">


_______________________________________________
grass-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:grass-dev@lists.osgeo.org">grass-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/grass-dev">http://lists.osgeo.org/mailman/listinfo/grass-dev</a>
</pre>
      </blockquote>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 

Paulo van Breugel
Department of Geosciences and Natural Resource Management
Section of Forest, Nature and Biomass
University of Copenhagen

Rolighedsvej 23
1958 Frederiksberg C
Phone: +45 353-31646
Phone: +31 6 12189147
e-mail: <a class="moz-txt-link-abbreviated" href="mailto:pvb@life.ku.dk">pvb@life.ku.dk</a>
e-mail: <a class="moz-txt-link-abbreviated" href="mailto:p.vanbreugel@gmail.com">p.vanbreugel@gmail.com</a>

</pre>
  </body>
</html>