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()" )

Glynn Clements wrote: 
> In this case, neither;

:D

> it's just converting strings to integers. The
> rows and cols values in the g.region output will always be integers.

Right... needles question (=I need to rest a bit).

> 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'

Thanks for details, Nikos
_______________________________________________
grass-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to