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

2013-05-21 Thread Glynn Clements
Paulo van Breugel wrote: In case you haven't seen it, Markus Metz has implemented in trunk r56313 http://trac.osgeo.org/grass/changeset/56313 the option to have the same raster type as output of round() as the input type, see ticket 1976 (http://trac.osgeo.org/grass/ticket/). I've seen

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

2013-05-20 Thread Glynn Clements
Markus Metz wrote: 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? Instead of r.mapcalc A = if(B==0,

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

2013-05-20 Thread Glynn Clements
Rainer M. Krug wrote: 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

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

2013-05-20 Thread Paulo van Breugel
On 05/20/2013 01:46 PM, Glynn Clements wrote: Markus Metz wrote: 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? Instead of

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

2013-05-17 Thread Glynn Clements
Rainer M. Krug wrote: 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

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

2013-05-17 Thread Paulo van Breugel
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? On Fri, May 17, 2013 at 4:38 PM, Glynn Clements

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

2013-05-17 Thread Rainer M. Krug
Glynn Clements gl...@gclements.plus.com writes: Rainer M. Krug wrote: 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,

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

2013-05-17 Thread Rainer M. Krug
Paulo van Breugel p.vanbreu...@gmail.com writes: 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? Yes

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

2013-05-17 Thread Markus Metz
On Fri, May 17, 2013 at 5:13 PM, Paulo van Breugel p.vanbreu...@gmail.com wrote: 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

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

2013-05-17 Thread Paulo van Breugel
Thanks Markus, That is certainly a good suggestion. The problem however remains I think with the part round(C / 0.0001) If C/0.0001 2^31, i.e., larger then the maximum possible integer, there will be an error. The white spaces, is that for another reason then being clearer? Cheers,

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

2013-05-16 Thread Rainer M. Krug
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

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

2013-05-16 Thread Paulo van Breugel
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. Cheers, Paulo On 05/16/2013 09:38 AM, Rainer M. Krug wrote: I just looked at the round function in xround.c, and it does not look to complicated to

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

2013-05-16 Thread Glynn Clements
Rainer M Krug wrote: 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? No.

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

2013-05-16 Thread Rainer M. Krug
Glynn Clements gl...@gclements.plus.com writes: Rainer M Krug wrote: 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

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

2013-05-15 Thread Paulo van Breugel
Hi, 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)/(300797-1175699902) *100.0, 1) --overwrite whereby C is a map with values between 1 and 31000.

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

2013-05-15 Thread Rainer M. Krug
Paulo van Breugel p.vanbreu...@gmail.com writes: Hi, I am having trouble with the following computation, which gives me an overflow warning (WARNING: Overflow occured in the calculation). oerflow usually means that the result of a calculation does not fit into the variable type selected,

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

2013-05-15 Thread Paulo van Breugel
Hi Rainer, Thanks a lot for your reply. The problem is indeed that the result of the calculation does not fit into the variable and your answer made me realize I had to take a closer look at what happens inside the formula. As it turns out, the problem lies in the following part of the

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

2013-05-15 Thread Glynn Clements
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)/(300797-1175699902) *100.0, 1) --overwrite whereby C is a map with

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

2013-05-15 Thread Rainer M Krug
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)/(300797-1175699902)

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

2013-05-15 Thread Paulo van Breugel
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,