[GRASS-dev] How to: if undefined, set to NULL?

Nikos Alexandris nik at nikosalexandris.net
Mon Sep 5 06:52:05 PDT 2016


Nikos Alexandris:

>> > Updated in sandbox, see: https://trac.osgeo.org/grass/changeset/69365
>> > Is it though correct?

Vaclav Petras wrote:

>> I was not looking at the logic but
>>
>> if (hue == -1.0) {
>>
>> is not safe. Although it will probably work most of the time if you set it
>> to the exactly same value (`hue = -1;`),

Glynn Clements <glynn at gclements.plus.com> [2016-09-05 16:46:31 +0100]:

>There's no "probably" about it. If you execute "hue = -1;", a
>subsequent "if (hue == -1)" comparison *will* succeed.
>
>Rounding error only occurs when the correct result isn't exactly
>representable, which isn't the case here. It doesn't occur randomly.

If using -1 is good, it seems simpler (to me, the ignorant) than trying
introducing yet another boolean flag.

Nikos


More information about the grass-dev mailing list