BitAnd issue with Int64 values


#1

Hi,

I’m trying to use a mask to clear some bits in a 64 bit integer (iMmiExch) with this snippet in a script block

[B] iMmiExch=iMmiExch bitand 0X7FFFFC73FFFFFFFF;[/B] //Clear all Sp StartStop Err Flags (bits 34,35,39,40,41)

iMmiExch remains unchanged after this step, regardless of the state of bits 34,35,39,40,41

This method works -

[B] iMmiExch=BitClear(iMmiExch, 34); [/B] // Clear the StartStop error state
[B]iMmiExch=BitClear(iMmiExch, 35); [/B] // Clear the prompt
[B]iMmiExch=BitClear(iMmiExch, 39);[/B] // Clear the StartStop error state
[B] iMmiExch=BitClear(iMmiExch, 40); [/B] // Clear the StartStop error state
[B] iMmiExch=BitClear(iMmiExch, 41); [/B] // Clear the StartStop error state

But it leaves me feeling like Mr Jones.

Any light you could shed would be appreciated.

Cheers,

Sam Grover


#2

Hi Sam,

I hope you don’t mind I moved your post, thought it deserved it’s very own thread…

By default, the OptoScript compiler assumes those literals values are int32s, so your mask there is getting truncated to a 32-bit value. Add “i64” at the end of that line (just before the semi-colon), then click your heels together three times and say: “we love OptoMary.” Okay, just kidding about that last part.

But you want:

iMmiExch=iMmiExch bitand 0X7FFFFC73FFFFFFFF[B]i64[/B];

Code on w/Bit 64s!

-Mary

BTW, if you don’t have our handy OptoScript syntax example handy, make sure you check this out too:
http://www.opto22.com/site/downloads/dl_drilldown.aspx?aid=4215


#3

I appended, I click thrice, I smiled. Thanks Mary