[GRASS-dev] Overflow warning in r.mapcalc calculation

Paulo van Breugel p.vanbreugel at gmail.com
Wed May 15 14:59:01 PDT 2013


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 <r.m.krug at gmail.com> wrote:

>
>
> On Wednesday, May 15, 2013, Glynn Clements wrote:
>
>>
>> Paulo van Breugel wrote:
>>
>> > 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,
>> (round(C/0.0001)-1175699902)/(3007966667-1175699902) *100.0, 1)" --overwrite
>> >
>> >
>> > 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.
>>
>> 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).
>
>
> 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
>
>
>>
>> --
>> Glynn Clements <glynn at gclements.plus.com>
>> _______________________________________________
>> grass-dev mailing list
>> grass-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/grass-dev
>>
>
>
> --
> 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:      Rainer at krugs.de
>
> Skype:      RMkrug
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20130515/28eaddf9/attachment.html>


More information about the grass-dev mailing list