Comparing a 64 bit Integer

Upon comparing a 64 bit integer, it seems as if I can not compare the value beyond the 30th bit level. So example:

If (Int64[0] == 1073741824) Then
String01 = “I know only bit 30 is ON”;
Elseif (Int64[0] == 2147483648) Then
String01 = “I know only bit 31 is ON”;
Endif

The program recognizes that Int64[0] == 1073741824 (which is the value of just bit 30 on), but not 2147483648 (which is the value of just bit 31 on or a 1)
So, I replaced the code with this, but it is not what I truly want, nor will it work with my application…

Elseif (IsBitOnInNumTableElement(0, Int64, 31)) Then
String01 = “I know bit 31 is On, but I don’t know if it is the only bit On”;

And that worked when I typed a value of 2147483648 for Int64[0].
Why won’t the first example work? Is there something I’m overlooking?
I am only simulating this in PAC Sim… Will it actually work with a SNAP PAC R1?
Any feedback would be appreciated.

To let the compiler know that your literal is an int64 (vs int32) add i64 to the end of it. For example:

If (Int64[0] == 1073741824i64) Then …

That’s all you need!

Awesome! Thanks.

That worked just fine.

I remember when I developed a 40+ command combobox in Pac Display and came to find out it doesn’t support Int64 (it says the value is not within range; max value to write was 2147483647)… I thought it was something in common with my current problem. … Anyways, did they ever fix that in PAC Display? Or is 2147483647 still the max value to write (meaning just the first 30 bits can be used)?

I appreciate the quick answer to this. Thanks. Have a great weekend.

You’re welcome!

I see this int64 table fix, might that have been what you ran into?
http://www.opto22.com/site/knowledgebase/kb_view_article.aspx?aid=1769

Is that combo box something you reported to our support team?

No, I never did report it.

If you go into PAC Display, make a new combobox. Add an “Item” (I called it “Turn Bit 31 ON”). Click on Send Value. Add an Int64 Tag. Then in the “Fixed data” field Type 2147483648 (which is Bit 31’s value). In Version R9.3b (which is what I have), it says “Integer not within required range”.
At that point, I just assumed the combobox in Pac Display only supported 32bit integers - Even though you can choose a 64bit Tag.

Like I said, I don’t know if they fixed it or you are limited to a 32bit integer for a combobox in Pac Display or if there is some other way around it.

I just tried this w/my 9.5, and it’s working fine!

Great, I’ll have to upgrade soon then. I just tried it here again and in Version R9.3b it throws up an error and seems to only support 32bit integers. Well done… You get the rest of the afternoon off with pay. :slight_smile:

Have a good weekend.

Whoo-hoo! Could you tell my boss that? :smile:

BTW, if/when you do upgrade to 9.5 (and we’re about to release a few patches to PAC Project 9.5, so you might want to wait until next week), there’s another way to do that bit-setting thing…

If you choose “Send Discrete…” instead of “Send Value…” it’ll let you specify a bit so you don’t have to do the math:

When you’ve selected to “Send Discrete…” it’ll prompt you for which bit:

Vs. the way you were doing it, which is works too, at least in 9.5:

Lots of choices! Just wanted to make sure you have a few to choose from.

You have an excellent weekend too!

Yeah, I tried the bit thing which does work, but it doesn’t clear the other bits in that particular Int64 Tag. In my application, I’m trying to set up 64 total commands with using only 1 value and only 1 command (bit) can happen at a time. So writing a “bit” value… example 1, 2, 4, 8, 16, 32, 64… 512, 1024 … -9223372036854775808 (bit 63) …etc., will only allow 1 bit to be ON at any given time within the same Int64 Tag.
By using Send Discrete, if the operator chooses from the list then changes his mind, the previous selection was never reset… Writing a Value does. -So, that’s why I have chosen to use Send Value.

Thanks again.