<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">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">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">https://gist.github.com/h-a-graham/6db16e70e064ae8173f1052537c59761#file-fmask-bitmask-vrt</a><br>the expression parsed as: "((Fmask & 8) > 0 || (Fmask & 4) > 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">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>