# [GRASSLIST:3633] Re: r.mapcalc - zero point bug

Glynn Clements glynn.clements at virgin.net
Tue Jun 8 22:20:10 EDT 2004

```Maciek Sieczka wrote:

> > A string of digits without a decimal point is interpreted as an
> > integer, which has a range of -2147483648 to 2147483647.
> >
> > If you add ".0" to the end (or even just "."), it will be interpreted
> > as a double-precision (64-bit) floating point value, which has a range
> > of approximately +/- 1.8e+308 with a precision of around 15 decimal
> > digits.
> >
> > Also, you can specify a single-precision (32-bit) floating point value
> > (range of approximately +/- 3.4e+38, with a precision of around 6
> > decimal digits) by appending "f" or "F" to the value, e.g. "1.2f".
> >
> > This is intentional behaviour. If you wish to specify a floating-point
> > constant, you have to include the decimal point.
>
> I'm sure there are reasons that it's "intentional" but also it's not
> intuitive for me and I believe for dozens like me.

The syntax and semantics of r.mapcalc expressions significantly
resemble those of the C language, which is probably the most
widely-known programming language. I would guess that this was
intentional.

I doubt that any syntax will be intuitive for everyone. In particular,
I suspect that people who only know one programming language will have
a tendency to assume similarities between that language and r.mapcalc.

> This may eventually get
> someone into troubles, don't you agree? Is  this issue explained somewhere
> in the Grass manual? I can't find it. I suggest it should be - IN CAPITALS.

The r.mapcalc manpage says:

: FLOATING POINT VALUES IN THE EXPRESSION
:        Floating  point  numbers  are allowed in the expression. A
:        floating point number is a number which contains a decimal
:        point:
:
:        2.3   12.   .81

Ultimately, the r.mapcalc manpage should include a full, inductive
definition of the language, rather than a number of ad-hoc statements
regarding specific aspects. Any volunteers?

--
Glynn Clements <glynn.clements at virgin.net>

```