13,138,881 members (53,431 online)
Rate this:
See more:
In my database we set 100663296 to be a GM Leader but also this field in the database gets written to for different things, so it changes that number to 100794368 i was told to possible use a bit-wise check to check whether the first number is the same as the second number, and I have googled on using bit-wise checks but got confused as to what to use for my check.

Here are some other numbers that change, including the one from above.

```predefined number   new changed number/ever changing number.
100663296       =       100794368
67108864        =       67239936
117440512       =       2231767040```

so how should i go about checking these numbers?

And here is part of my code that i was using before i noticed the change in the numbers.

```<pre lang="xml">if (playerData[i].nameflags == 67108864)
{
playerRows += &#39;&lt;img src =&quot;icons/GM-Icon.png&quot; alt=&quot;GM&quot; title=&quot;GM&quot;&gt;&lt;/img&gt;&#39;;
}</pre>```
Posted 27-Feb-13 13:19pm

Rate this:

## Solution 1

If you need to check for full bitwise equality of two integers, all you need is just '==' operator, but to use it, you should guarantee that both operands are integers:

```left = 12323;
right = 12323;
if (left == right)
alert("Operands are binary equal; I'll guarantee that. :-)");```

Be very careful though; if at least one of operands is string representing number, not a number, both operands will be considered strings and you can get confusing results:

```left = "012323";
right = 12323;
if (left != right)
alert("Operands are not equal, even though they represent 'equal values', as they are compared as strings.");```

In general, these days, the attempt to operate with strings representing data instead of data itself is a real curse of the beginners; and it's hard to explain to them. It is especially difficult to explain in JavaScript, with its loose-type typing concept, which is itself very complex and hard to understand, behind the illusory simplicity.

Finally, if you need to compare separate bits (and, from your question, I don't see this need), you can use binary operators:
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Bitwise_Operators[^].

That's it, basically.

—SA

Top Experts
Last 24hrsThis month
 Graeme_Grant 518 OriginalGriff 329 Karthik Bangalore 155 CPallini 155 Kornfeld Eliyahu Peter 120
 OriginalGriff 4,764 Graeme_Grant 4,510 ppolymorphe 1,644 Jochen Arndt 1,522 CPallini 1,310