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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BITWISE AND OPERATOR FOR FORMULA 1

Status
Not open for further replies.

pyttviper

MIS
May 15, 2001
37
US
I am creating a formula to return a value based on a bitwise comparrison listed here
({AssetCoordinate.AssetCoordinateFlags} ?????? 65536) >0
the ????? is the 'bitwise and' that i can't find in crystal

in T-sql it is "&"

This statement is evaluated in an if statement with the results 1 if true and 0 if false.

thanks
dan0
 
I don't know whether there is a bitwise "and" built into Crystal. If there isn't, you can write one yourself. If you divide a number by two, this shifts it one bit to the left, then you can use the Remainder(x, 2) to give you the value of the leftmost (smallest order) bit (0 or 1).

To do an "and" comparison, you'll have to compare the remainders on both operands for the leftmost bit (1 and 1 = 1; anything else = 0), shift both operands to the left, compare again for the second bit, etc. etc. until you compare all bits. It may be more trouble than it's worth, but it's one way to get the result you want.

I hope this makes sense. If not, I'll try to clarify.
Mary

 
What does "bitwise and" mean in English?

If it is adding or concatenating the operator in CR is "+" in both cases. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
A "bitwise and" is a binary operation that performs an "and" on each bit of the two numbers, like this:

1 and 1 = 1
1 and 0 = 0
0 and 1 = 0
0 and 0 = 0

With a longer number, say 11 and 5, you'd get this, if the 1's column is on the left, and the 8's column is on the right:

1 1 0 1 (11 in binary: 1 + 2 + 0 + 8)
1 0 1 0 ( 5 in binary: 1 + 0 + 4 + 0)
1 0 0 0 (result = 1 in binary)

Mary
 
Sorry, I don't think I will be any help on this one. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top