<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    No inconvenience - general list etiquette usually says start with
    'user' and then move to 'dev' if it looks like a SW issue.<br>
    But I am NOT lecturing you, so please do not take offense.<br>
    <br>
    Keep well,<br>
    Zoltan<br>
    <br>
    <div class="moz-cite-prefix">On 2021-01-24 18:28, ming han wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAD+uAWhXd+zTW5QcZdQri3yaXujkbz=ZTiDTMtiLEt3FTb-OQA@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">sorry for the inconvenience. I was just not sure if
        it is problem that needs developers to answer. 
        <div>Best regards</div>
        <div>Ming  </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">Zoltan <<a
            href="mailto:zoltans@geograph.co.za" moz-do-not-send="true">zoltans@geograph.co.za</a>>
          于2021年1月24日周日 上午11:13写道:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div> Hi,<br>
            Is it important to cross-post this discussion on both dev
            and user lists?<br>
            <br>
            Regards,<br>
            Zoltan<br>
            <br>
            <br>
            <div>On 2021-01-24 17:56, Markus Metz wrote:<br>
            </div>
            <blockquote type="cite">
              <div dir="ltr">
                <div>Trying to answer the original question: with a
                  DCELL map "cat1_acc_riv" and a FCELL map
                  "cat1_minacc", why is "float(cat1_acc_riv) ==
                  float(cat1_minacc)" not equal to "int(cat1_acc_riv) ==
                  int(cat1_minacc)" ?<br>
                </div>
                <div><br>
                </div>
                <div>int truncates to integer while float converts to
                  single precision floating point. E.g. with
                  cat1_acc_riv = 1.1 and cat1_minacc = 1.9,
                  "float(cat1_acc_riv) == float(cat1_minacc)" becomes
                  "1.1 == 1.9" whereas "int(cat1_acc_riv) ==
                  int(cat1_minacc)" becomes "1 == 1", thus the results
                  are different.</div>
                <div><br>
                </div>
                <div>Another reason for possible differences is that
                  float can only represent max 7 decimal digits. E.g.
                  float(194320567) becomes 194320560 but int(194320567)
                  preserves the value 194320567.</div>
                <div><br>
                </div>
                <div>Thus the safest is to cast everything to the type
                  with the highest precision. In this case with FCELL
                  and DCELL, use "double(cat1_acc_riv) ==
                  double(cat1_minacc)" or even better the suggestion of
                  Markus N.</div>
                <div><br>
                </div>
                <div>Markus M<br>
                </div>
                <div><br>
                </div>
                <div><br>
                  On Sun, Jan 24, 2021 at 3:51 PM ming han <<a
                    href="mailto:dustming@gmail.com" target="_blank"
                    moz-do-not-send="true">dustming@gmail.com</a>>
                  wrote:<br>
                  ><br>
                  > Hi Markus and Micha<br>
                  ><br>
                  >      I am just trying to find grids have the same
                  values in these two rasters, I will try the threshold
                  approach.<br>
                  ><br>
                  > Thanks<br>
                  > Ming <br>
                  ><br>
                  > Markus Neteler <<a
                    href="mailto:neteler@osgeo.org" target="_blank"
                    moz-do-not-send="true">neteler@osgeo.org</a>>
                  于2021年1月24日周日 上午6:58写道:<br>
                  >><br>
                  >> Hi Ming,<br>
                  >><br>
                  >> On Sun, Jan 24, 2021 at 10:49 AM ming han
                  <<a href="mailto:dustming@gmail.com"
                    target="_blank" moz-do-not-send="true">dustming@gmail.com</a>>
                  wrote:<br>
                  >> ><br>
                  >> > Hi Micha<br>
                  >> ><br>
                  >> >      Many thanks for your reply.<br>
                  >> >      Here is the command I am using:<br>
                  >> ><br>
                  >> >      if(float(cat1_acc_riv) ==
                  float(cat1_minacc), str_r, null())<br>
                  >> ><br>
                  >> >       The str_r is a CELL raster. the
                  result is different when I change it to:<br>
                  >> >        if(int(cat1_acc_riv) ==
                  int(cat1_minacc), str_r, null())<br>
                  >><br>
                  >> Note that numerical "equality" is better
                  tested with a threshold test<br>
                  >> against the map pixel difference.<br>
                  >> As the threshold, we use GRASS_EPSILON which
                  is defined as 1.0e-15.<br>
                  >><br>
                  >> Hence the test needs to be implemented in a
                  different way, i.e. by<br>
                  >> using an epsilon.<br>
                  >> Essentially something like this:<br>
                  >><br>
                  >> if(fabs(map_A - map_B) <= 1.0e-15, ... )<br>
                  >><br>
                  >> In your case (untested):<br>
                  >> r.mapcalc diffepsilon = if( abs( map_A -
                  map_B) <= 1.0e-15, str_r , null())<br>
                  >><br>
                  >> See related discussions here: [1], [2] and
                  elsewhere.<br>
                  >><br>
                  >> [1] Comment by Glynn: <a
                    href="https://trac.osgeo.org/grass/ticket/2854#comment:9"
                    target="_blank" moz-do-not-send="true">https://trac.osgeo.org/grass/ticket/2854#comment:9</a><br>
                  >> [2] Comment by Glynn:<br>
                  >> <a
href="https://lists.osgeo.org/pipermail/grass-user/2015-October/073200.html"
                    target="_blank" moz-do-not-send="true">https://lists.osgeo.org/pipermail/grass-user/2015-October/073200.html</a><br>
                  >><br>
                  >> Best,<br>
                  >> Markus<br>
                  ><br>
                  > _______________________________________________<br>
                  > grass-dev mailing list<br>
                  > <a href="mailto:grass-dev@lists.osgeo.org"
                    target="_blank" moz-do-not-send="true">grass-dev@lists.osgeo.org</a><br>
                  > <a
                    href="https://lists.osgeo.org/mailman/listinfo/grass-dev"
                    target="_blank" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/grass-dev</a></div>
              </div>
              <br>
              <fieldset></fieldset>
              <pre>_______________________________________________
grass-dev mailing list
<a href="mailto:grass-dev@lists.osgeo.org" target="_blank" moz-do-not-send="true">grass-dev@lists.osgeo.org</a>
<a href="https://lists.osgeo.org/mailman/listinfo/grass-dev" target="_blank" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/grass-dev</a>
</pre>
            </blockquote>
            <br>
            <pre cols="72">-- 

=============================================
Zoltan Szecsei GPrGISc 0031
Geograph (Pty) Ltd.
GIS and Photogrammetric Services

Cape Town, South Africa.

Mobile: +27-83-6004028
<a href="http://www.geograph.co.za" target="_blank" moz-do-not-send="true">www.geograph.co.za</a>
=============================================
</pre>
          </div>
          _______________________________________________<br>
          grass-dev mailing list<br>
          <a href="mailto:grass-dev@lists.osgeo.org" target="_blank"
            moz-do-not-send="true">grass-dev@lists.osgeo.org</a><br>
          <a href="https://lists.osgeo.org/mailman/listinfo/grass-dev"
            rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/grass-dev</a><br>
        </blockquote>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 

=============================================
Zoltan Szecsei GPrGISc 0031
Geograph (Pty) Ltd.
GIS and Photogrammetric Services

Cape Town, South Africa.

Mobile: +27-83-6004028
<a class="moz-txt-link-abbreviated" href="http://www.geograph.co.za">www.geograph.co.za</a>
=============================================
</pre>
  </body>
</html>