[GRASS5] An error in v.surf.idw main program --- may be a bug.

Hi all;

While i am compiling the grass source codes gcc shows a warning. for the line

/* interpolate */
sum1 = 0.0;
sum2 = 0.0;
for (n = 0; n < nsearch; n++)
{
if(dist = list[n].dist)
{

The code is like that in both 6.0.1 version and 6.0.2RC1.
is it an error or anythig else. i think it must be;

if ( dist == list[n].dist)

Best regards…
Muzaffer


Yahoo! Photos
Ring in the New Year with Photo Calendars. Add photos, events, holidays, whatever.

Hi Muzaffer,

The statement "if ( dist = list[n].dist )" is correct. it should perhaps
be re-written to "if ( list[n].dist == 0.0 )" and then assignd "dist =
list[n].dist;" in the if-block (or use "list[n].dist" as the divisor),
to make it explicit what we are doing. if dist is zero then the distance
to one of the sites is zero, and we simply use the site value instead.

--Wolf

--

<:3 )---- Wolf Bergenheim ----( 8:>

On 30/12/05 19:53, Muzaffer Ayvaz wrote:

Hi all;
   
  While i am compiling the grass source codes gcc shows a warning. for the line
   
  .....
    /* interpolate */
  sum1 = 0.0;
  sum2 = 0.0;
  for (n = 0; n < nsearch; n++)
  {
  if(dist = list[n].dist)
  {
  
  The code is like that in both 6.0.1 version and 6.0.2RC1.
  is it an error or anythig else. i think it must be;
   
    if ( dist == list[n].dist)
   
  Best regards...
  Muzaffer
   

Muzaffer Ayvaz wrote:

  While i am compiling the grass source codes gcc shows a warning. for the line
   
  .....
    /* interpolate */
  sum1 = 0.0;
  sum2 = 0.0;
  for (n = 0; n < nsearch; n++)
  {
  if(dist = list[n].dist)
  {
  
  The code is like that in both 6.0.1 version and 6.0.2RC1.
  is it an error or anythig else.

No, it's correct, but could be written better as:

  dist = list[n].dist;
  if (dist)
    ...
or:
  if(dist = list[n].dist, dist)

i think it must be;
   
    if ( dist == list[n].dist)

No, the assignment must be performed.

--
Glynn Clements <glynn@gclements.plus.com>