<div><div><div>Hi all,</div><div> </div><div>I ran into the issue regarding defined macros and bitwise operators bor/band/bxor.</div><div>The output result depends on whether the parentheses are set or not.</div><div> </div><div>The code below shows this behaviour:</div><div> </div><div>-------------------------------------------------------------------------------------------------------------------</div><div>-module(test).</div><div> </div><div>-export([print/0]).</div><div> </div><div>-define(NUM1, 2#01).</div><div>-define(NUM2, ?NUM1 bsl 1).</div><div> </div><div>-define(NUM_BOR_PAR, (?NUM1) bor (?NUM2)).</div><div>-define(NUM_BOR_NO_PAR, ?NUM1 bor ?NUM2).</div><div> </div><div>-define(NUM_BAND_PAR, (?NUM1) band (?NUM2)).</div><div>-define(NUM_BAND_NO_PAR, ?NUM1 band ?NUM2).</div><div> </div><div>-define(NUM_BXOR_PAR, (?NUM1) bxor (?NUM2)).</div><div>-define(NUM_BXOR_NO_PAR, ?NUM1 bxor ?NUM2).</div><div> </div><div>print() -></div><div>    io:format("NUM1: ~p~n", [?NUM1]),</div><div>    io:format("NUM2: ~p~n", [?NUM2]),</div><div>    io:format("NUM_BOR_PAR: ~p~n", [?NUM_BOR_PAR]),</div><div>    io:format("NUM_BOR_NO_PAR: ~p~n", [?NUM_BOR_NO_PAR]),</div><div>    io:format("NUM_BAND_PAR: ~p~n", [?NUM_BAND_PAR]),</div><div>    io:format("NUM_BAND_NO_PAR: ~p~n", [?NUM_BAND_NO_PAR]),</div><div>    io:format("NUM_BXOR_PAR: ~p~n", [?NUM_BXOR_PAR]),</div><div>    io:format("NUM_BXOR_NO_PAR: ~p~n", [?NUM_BXOR_NO_PAR]),</div><div>    ok.</div><div> </div><div>-------------------------------------------------------------------------------------------------------------------</div><div> </div><div>In shell:</div><div> </div><div>$ erl</div><div>Erlang/OTP 22 [erts-10.4.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]</div><div> </div><div>Eshell V10.4.1  (abort with ^G)</div><div> </div><div>1> c(test).</div><div>{ok,test}</div><div>2> test:print().</div><div>NUM1: 1</div><div>NUM2: 2</div><div>NUM_BOR_PAR: 3</div><div>NUM_BOR_NO_PAR: 2</div><div>NUM_BAND_PAR: 0</div><div>NUM_BAND_NO_PAR: 2</div><div>NUM_BXOR_PAR: 3</div><div>NUM_BXOR_NO_PAR: 0</div><div>ok</div><div> </div><div>-----------------------------------------</div><div> </div><div>Is there any explanation of such syntax in the OTP docs?</div><div> </div><div>I'm using OTP 22.0.2</div><div> </div></div></div>