csound / csound.github.io

Csound Project Homepage
25 stars 27 forks source link

32bit limitation in bitwise logic opcodes, except | (or) #93

Closed janahuebenthal closed 1 year ago

janahuebenthal commented 1 year ago

I ran into oddities while using bitwise logic with huge numbers. They are not working as expected on 64bit Csound.

You will find a boiled down version of my analysis in the attached csd (renamed to *.txt due to file type limits). bitwise.txt

Tested with Csound 6.17 in Ubuntu and Win10.

Cheers, Jana

vlazzarini commented 1 year ago

Thanks for this. We'll investigate. It's likely that we are using 32bit ints. We may be able to change this for Csound 7.

vlazzarini commented 1 year ago

Yes, they are using 32bit ints, rounded from MYFLT. I also found out two things

So we should make these using 64bit ints when MYFLT is double (is that right @jpffitch ?) and get them back working in Csound 7

vlazzarini commented 1 year ago

The issue with the manual example is precedence.

if (ipp & ivalue >= ivalue)

in Csound 6.x is if ((ipp & ivalue) >= ivalue) but it seems to be if (ipp & (ivalue >= ivalue)) in Csound 7 causing the code to fail to compile. What do you reckon, @kunstmusik ?

vlazzarini commented 1 year ago

done on develop branch