<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000099">
Thanks for that Rainer. I have no expertise in C too, but let me
file a feature / enhancement request, perhaps somebody can pick this
up.<br>
<br>
Cheers,<br>
<br>
Paulo<br>
<br>
<br>
<br>
<div class="moz-cite-prefix">On 05/16/2013 09:38 AM, Rainer M. Krug
wrote:<br>
</div>
<blockquote cite="mid:877gize5mv.fsf@krugs.de" type="cite">
<pre wrap="">
I just looked at the round function in xround.c, and it does not look to
complicated to modify round() to obtain have three more functions, aligned to the
R functions:
>From the R help:
,----
| ‘ceiling’ takes a single numeric argument ‘x’ and returns a
| numeric vector containing the smallest integers not less than the
| corresponding elements of ‘x’.
|
| ‘floor’ takes a single numeric argument ‘x’ and returns a numeric
| vector containing the largest integers not greater than the
| corresponding elements of ‘x’.
|
| ‘trunc’ takes a single numeric argument ‘x’ and returns a numeric
| vector containing the integers formed by truncating the values in
| ‘x’ toward ‘0’.
`----
In addition, an additional argument could be added to the round()
function to round to the number of specified decimal places, so that it
is equivalent to your suggestion, Paulo.
>From the R help:
,----
| ‘round’ rounds the values in its first argument to the specified
| number of decimal places (default 0).
`----
Unfortunately I don't have the experience in C and absolutely no time at
the moment to get into it.
Cheers,
Rainer
Paulo van Breugel <a class="moz-txt-link-rfc2396E" href="mailto:p.vanbreugel@gmail.com"><p.vanbreugel@gmail.com></a> writes:
</pre>
<blockquote type="cite">
<pre wrap="">I would second that, it certainly would be handy to be able to round
numbers outside the integer range and in addition, rounding with a specific
number of decimal places, like e.g., the function round() in R. Is there a
specific reason the round() function results in an integer?
Paulo
On Wed, May 15, 2013 at 9:20 PM, Rainer M Krug <a class="moz-txt-link-rfc2396E" href="mailto:r.m.krug@gmail.com"><r.m.krug@gmail.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">
On Wednesday, May 15, 2013, Glynn Clements wrote:
</pre>
<blockquote type="cite">
<pre wrap="">
Paulo van Breugel wrote:
</pre>
<blockquote type="cite">
<pre wrap="">I am having trouble with the following computation, which gives me an
overflow warning ("WARNING: Overflow occured in the calculation").
r.mapcalc "A = if(B==0,
</pre>
</blockquote>
<pre wrap="">(round(C/0.0001)-1175699902)/(3007966667-1175699902) *100.0, 1)" --overwrite
</pre>
<blockquote type="cite">
<pre wrap="">
whereby C is a map with values between 1 and 31000. It seems to be
related to the size of the numbers (no warning if I divide C by 0.001),
but I am not clear what limit I am hitting here or how to avoid this.
The warning does not stop the calculation, and the resulting map seems
to be correct. However, I rather avoid this warning, also because the
warning message causes problems when running in batch from within R.
</pre>
</blockquote>
<pre wrap="">
The round() function always returns an integer, regardless of its
argument types. Integers are always 32-bit, so the result is limited
to the range +/- 2147483647 (2^31-1).
</pre>
</blockquote>
<pre wrap="">
True - but is there an equivalent function to round numbers outside the
integer range? Would be useful. Looking at the functions in r.mapcalc, I
can't think of a way of doing this?
Rainer
</pre>
<blockquote type="cite">
<pre wrap="">
--
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="">
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)
Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa
Tel : +33 - (0)9 53 10 27 44
Cell: +33 - (0)6 85 62 59 98
Fax (F): +33 - (0)9 58 10 27 44
Fax (D): +49 - (0)3 21 21 25 22 44
email: <a class="moz-txt-link-abbreviated" href="mailto:Rainer@krugs.de">Rainer@krugs.de</a>
Skype: RMkrug
</pre>
</blockquote>
</blockquote>
<pre wrap="">
</pre>
</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>