Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

workaround 32-bit limit with &-operator

Status
Not open for further replies.

TheSaint99

Technical User
Apr 20, 2001
13
0
0
GB
Hi,

I have a collection of items that can be selected through a listbox. I store the selection in a variable by using the bitwise operator.
for example I have 4 items:

one
two
three
four

If I select nothing, my variable is 0. If I select one, my variable is 1(2^0). If i only select three, my variable is 4(2^2) and when i select one and three the variable would be 5 (2^0+2^2).

This way of storing the selection is working perfectly until I have more than 31 items in the collection, because then the operator has problems with the 32-bit limit in javascript. Is there a way to work around this problem with the limit? Does anyone has suggestions?

Thnx

TheSaint99
 

You could store the selections in an array. That has no such limit.

Granted, the memory taken to store 31 items would be 31 bytes, instead of 4, but that isn't a huge amount of memory, I'm sure you'll agree.

Hope this helps,
Dan


The answers you get are only as good as the information you give!

 
You could also use a REAL STRING representation of the BIT STRING" you are currently using. The limit on the length of a string shouldn't be a problem. Instead of storing 5 (0101) store "0101". Use the string parsing commands to extract the information.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top