Rounding of floating numbers in GRASS GIS r.mapcalc

The GRASS GIS development team keeps on introducing new features and enhancements to GRASS 7.0. One of the latest examples is the enhancement of the round() function in r.mapcalc. Previously this function would always returns an integer, regardless of its argument types. And because integers are always 32-bit, the result was limited to the range ± 2147483647 (2^31-1).

These limitations have been removed in the latest update of grass 7.0 (trunk r56313). Now the output type of round() is the same as the input type. Rounding to a given number of decimal places is supported with round(x, y) where y = number of decimal places.

In addition, the new function round(x, y) supports a negative number of decimal places: for example, round(119, -1) results in 120, and round(119, -2) results in 100.
Again great work by the GRASS development team!

Rounding a double precision raster layers (twi_900mm) to two decimals places (test).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s