Nikos Alexandris wrote:
> Nikos Alexandris wrote:
> > > > > >> rows = int(grass.region()['rows'])
> > > > > >> cols = int(grass.region()['cols'])
> Is python's "int()" truncating or rounding up values? The question came to
> me
> while thinking of r.mapcalc's respective functions ( i.e. "int() != round()" )
In this case, neither; it's just converting strings to integers. The
rows and cols values in the g.region output will always be integers.
If you pass a floating-point value to int(), it will be truncated
(i.e. rounded towards zero):
> int(1.9)
1
> int(-1.9)
-1
If you pass a string containing a decimal point to int(), it will
raise an exception:
> int("1.9")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '1.9'
--
Glynn Clements <[email protected]>
_______________________________________________
grass-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-user