<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>I see there's a <a class="moz-txt-link-freetext" href="mu::ParserInt">mu::ParserInt</a> class in
<a class="moz-txt-link-freetext" href="https://github.com/beltoforion/muparser/blob/master/include/muParserInt.h">https://github.com/beltoforion/muparser/blob/master/include/muParserInt.h</a>
      , that we don't use in GDAL. A bit strange it wasn't mentionned in
      [1]. Perhaps because of this comment: "This version of the parser
      handles only integer numbers. It disables the built in operators
      thus it is slower than muParser. Integer values are stored in the
      double value_type and converted if needed."</p>
    <div class="moz-cite-prefix">Le 03/12/2025 à 21:07, Daniel Baston
      via gdal-dev a écrit :<br>
    </div>
    <blockquote type="cite"
cite="mid:CA+K_q_oUT_9F9-qSJtxUk59DaTXC=AY98xSMz07_fy4az+L5BA@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr">
          <div>Hugh,</div>
          <div><br>
          </div>
          <div>My read of this discussion [1] is that bitwise operators
            are not supported and we would need to add them as a GDAL
            extension. This is pretty easy to do: see [2].
            Alternatively, bitwise operators are probably supported by
            the ExprTk expression parser [3] (supported by GDAL) or this
            pull request [4].</div>
          <div><br>
          </div>
          <div>Dan</div>
          <div><br>
          </div>
          <div>[1] <a
href="https://github.com/beltoforion/muparser/discussions/154#discussioncomment-13104418"
              moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/beltoforion/muparser/discussions/154#discussioncomment-13104418</a></div>
          <div>[2] <a
              href="https://github.com/OSGeo/gdal/pull/13187/files"
              moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/OSGeo/gdal/pull/13187/files</a></div>
          <div>[3] <a href="https://www.partow.net/programming/exprtk/"
              moz-do-not-send="true" class="moz-txt-link-freetext">https://www.partow.net/programming/exprtk/</a> </div>
        </div>
        [4] <a href="https://github.com/OSGeo/gdal/pull/13470"
          moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/OSGeo/gdal/pull/13470</a></div>
      <br>
      <div class="gmail_quote gmail_quote_container">
        <div dir="ltr" class="gmail_attr">On Wed, Dec 3, 2025 at 2:58 PM
          Hugh Graham via gdal-dev <<a
            href="mailto:gdal-dev@lists.osgeo.org"
            moz-do-not-send="true" class="moz-txt-link-freetext">gdal-dev@lists.osgeo.org</a>>
          wrote:<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 dir="ltr">
            <div dir="ltr">Hi, <br>
              <br>
              I am using VRT muparser expressions for bitwise operations
              when creating masks and wanted to understand why I can't
              get the <i>bitwise & </i>operator working? My
              current solution is to use fmod which is fine (and I think
              equivalent) but using "&" would be convenient and a
              bit easier to read...<br>
              <br>
              To illustrate, the following file works: <br>
              <a
href="https://gist.github.com/h-a-graham/6db16e70e064ae8173f1052537c59761#file-fmask-fmodmask-vrt"
                target="_blank" moz-do-not-send="true"
                class="moz-txt-link-freetext">https://gist.github.com/h-a-graham/6db16e70e064ae8173f1052537c59761#file-fmask-fmodmask-vrt</a> <br>
              the expression used here is:"(fmod(Fmask, 16) >= 8) ||
              (fmod(Fmask, 8) >= 4) ? 0 : 1"<br>
              <br>
              ```<br>
              gdal convert "/vsicurl/<a
href="https://gist.githubusercontent.com/h-a-graham/6db16e70e064ae8173f1052537c59761/raw/c48b15852bcc7c5252cae4b906c14b9a3205a33d/fmask-fmodmask.vrt"
                target="_blank" moz-do-not-send="true"
                class="moz-txt-link-freetext">https://gist.githubusercontent.com/h-a-graham/6db16e70e064ae8173f1052537c59761/raw/c48b15852bcc7c5252cae4b906c14b9a3205a33d/fmask-fmodmask.vrt</a>"
              "test.tif"<br>
              ```<br>
              <br>
              However, the following file fails: <br>
              <a
href="https://gist.github.com/h-a-graham/6db16e70e064ae8173f1052537c59761#file-fmask-bitmask-vrt"
                target="_blank" moz-do-not-send="true"
                class="moz-txt-link-freetext">https://gist.github.com/h-a-graham/6db16e70e064ae8173f1052537c59761#file-fmask-bitmask-vrt</a><br>
              the expression parsed as: "((Fmask &amp; 8) &gt; 0
              || (Fmask &amp; 4) &gt; 0) ? 0 : 1" in the XML but
              provided as (to my xml parser):<br>
              <br>
              "((Fmask & 8) > 0 || (Fmask & 4) > 0) ? 0 :
              1"<br>
              <div><br>
              </div>
              <div>```</div>
              <div>gdal convert "/vsicurl/<a
href="https://gist.githubusercontent.com/h-a-graham/6db16e70e064ae8173f1052537c59761/raw/c48b15852bcc7c5252cae4b906c14b9a3205a33d/fmask-bitmask.vrt"
                  target="_blank" moz-do-not-send="true"
                  class="moz-txt-link-freetext">https://gist.githubusercontent.com/h-a-graham/6db16e70e064ae8173f1052537c59761/raw/c48b15852bcc7c5252cae4b906c14b9a3205a33d/fmask-bitmask.vrt</a>"
                "test.tif"<br>
                0...10...20..ERROR 1: Unexpected token "& 8) > 0
                || (Fmask & 4) > 0) ? 0 : 1 " found at position
                8.</div>
              <div>``` <br>
                <br>
                So, is using "&" possible, or should I just stick
                with fmod and not worry about it?<br>
                <br>
                Any help would be much appreciated. <br>
                <br>
                Hugh<br>
                <br>
                <br>
                <br>
                <br>
                <br>
                <br>
              </div>
            </div>
          </div>
          _______________________________________________<br>
          gdal-dev mailing list<br>
          <a href="mailto:gdal-dev@lists.osgeo.org" target="_blank"
            moz-do-not-send="true" class="moz-txt-link-freetext">gdal-dev@lists.osgeo.org</a><br>
          <a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev"
            rel="noreferrer" target="_blank" moz-do-not-send="true"
            class="moz-txt-link-freetext">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
        </blockquote>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre wrap="" class="moz-quote-pre">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
  </body>
</html>