View Full Version : not understanding BITWISE - how to compare bitwise?
06-18-2004, 01:19 AM
I am doing matching on 'matching bitwise' ---> but its not working...
how do you compare and match and return a true?????
06-18-2004, 02:07 AM
did you not have a lengthy discussion with liorean over this?
06-18-2004, 02:17 AM
yes, but it was very confusing - though thoroughly explained....
06-18-2004, 03:46 AM
What are the values to be compared?
06-18-2004, 04:04 AM
the items are already in numeric...
Just comparing numbers.....there is no specific values, as they will change depending on what a person selects.....but, for example.....
7 to 1
1 to 0
2,1,1 to 4,1,0
16 to 3
16 to 14
I need to know if they match or are true....if that is possible.
06-18-2004, 04:14 AM
Maybe I'm missing something, but wouldn't (value == value) either return true or false?
I think the bitwise comparison is automatic.
neofibril is right. See the code below to better understand this
06-18-2004, 01:18 PM
You are once again making the mistake of asking a general question regarding a specific problem and failing to provide any code so that someone can see what is going on.
You state both "the items are already in numeric" and "there is no specific values, as they will change depending on what a person selects".....
How sure are you that the values are indeed numerics and not strings?
Where are the values coming from?
Can we see some code please?
anyway, the solution is the same. To return a boolean value of a bitwise comparasion use Boolean() method. Of course, you have to be sure that both values are the same type, or both are numbers or both are strings.
06-18-2004, 04:16 PM
as long as you arent getting one number from a pulldown, and one from a textbox, the above solution should work. even if you are getting one from each, you could either use the Boolean() method on one or the toString() method on the other (although that may only be in Java, not JS)
06-18-2004, 08:40 PM
let me give this a go...I wasn't familiar with the "boolean" method...
06-18-2004, 08:44 PM
let us know how it turns out :)
In fact there is no need of a special method as bitwise is an implicit operation
will return false
Interesting is that bitwise comparation laways bypasses the string/number differeneces. Thus
will give the same boolean result : true
Thus, canadianjameson, you are wrong, as you don't need to know if the value input is a string or a number.
06-22-2004, 08:59 PM
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.