Maciej Sieczka pisze:
Maciej Sieczka pisze:
Glynn Clements pisze:
Maciej Sieczka wrote:
$ r.mapcalc 'map=rand(-2147483648,2147483647)'
res[i] = (lo == hi) ? lo : lo + x % (hi - lo);
The expression (hi - lo) is overflowing the range of a signed integer.
Are all GRASS modules limited to Int32, ie. -2147483648 to 214748364? I
can see r.mapcalc silently forces 214748364 for anything bigger...
This is not entirely correct. More findings:
The following silently forces 2147483647 on anything bigger:
$ r.mapcalc 'map=9999999999999999999'
$ r.info -rt map
min=2147483647
max=2147483647
datatype=CELL
This one too, though I'm trying to enforce double:
$ r.mapcalc 'map=double(9999999999999999999)'
$ r.info -rt map
min=2147483647.000000
max=2147483647.000000
datatype=DCELL
Trying the same by adding a decimal place separator, results in
something bizzare to me:
$ r.mapcalc 'map=99999999999999999999999.0'
$ r.info -rt map
min=99999999999999991611392.000000
max=99999999999999991611392.000000
datatype=DCELL
$ r.mapcalc 'map=9999999999999999999.0'
$ r.info -rt map
min=10000000000000000000.000000
max=10000000000000000000.000000
datatype=DCELL
At the edges of Float32 range other strange things happen:
Shouldn't the below be rather
min,max=340282000000000000000000000000000000000.0?:
$ r.mapcalc 'map=3.40282e38'
$ r.info -rt map
min=340282000000000014192072600942972764160.000000
max=340282000000000014192072600942972764160.000000
datatype=DCELL
The the one below should be -340282000000000000000000000000000000000.0 I
guess:
$ r.mapcalc 'map=-3.40282e38'
$ r.info -rt map
min=-340282000000000014192072600942972764160.000000
max=-340282000000000014192072600942972764160.000000
datatype=DCEL
At bigger Float64 values r.mapcalc crashes:
$r.mapcalc 'map=3.40282e110'
*** stack smashing detected ***: r.mapcalc terminated
Aborted (core dumped)
$ r.mapcalc 'map=1.79769e+308'
100%
*** stack smashing detected ***: r.mapcalc terminated
Aborted (core dumped
BTW, what are the NULL value for double and float?
Still curious (to document it).
Maciek
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev