Tiago Veloso
Tiago Veloso

Reputation: 8563

Logical (AND, OR, XOR) over Long

I am extending a tool in Java that somehow is capable of applying Logical (AND, OR and XOR) over three Long values.

How is that possible? If it is possible?

Upvotes: 0

Views: 5253

Answers (3)

guido
guido

Reputation: 19194

Maybe they wanted to implement IDL-like logical operators

Default Definitions of True and False

Data Type                    True                              False 
====================================================================================
Byte,integer, and long       Odd integers                      Zero or even integers 
Floating point and complex   Non-zero values                   Zero 
String                       Any string with non-zero length   Null string (" ") 
Heap variables               Non-null values                   Null values

Upvotes: 2

Bohemian
Bohemian

Reputation: 424993

You can apply bit-wise operators on longs:

  • & is AND
  • | is OR
  • ^ is XOR

Upvotes: 4

Petar Minchev
Petar Minchev

Reputation: 47373

What do you mean by not possible? 3 | 4 | 5 is a perfectly valid expression as 3 & 4 & 5.

Upvotes: 2

Related Questions