Android Question Bit.And operation

masky

Member
Licensed User
Longtime User
Hello everyone,

I want to make and AND logic operation, using two long variables. I know that Bit.AND is only for integer type, so I'm asking for long types.

Thnak you in advance.
 

MLDev

Active Member
Licensed User
Longtime User
B4X:
Sub And64Bits(a As Long, b As Long) As Long
  Dim c As Long = Bit.And(Bit.And(a / Power(2, 48), 65535), Bit.And(b / Power(2, 48), 65535))
 
  For j = 1 To 3
      a = a * 65536
      b = b * 65536
      c = c * 65536 + Bit.And(Bit.And(a / Power(2, 48), 65535), Bit.And(b / Power(2, 48), 65535))
  Next
 
  Return c
End Sub
 
Upvote 0

masky

Member
Licensed User
Longtime User
Hello MLDev,

thank you for your help, but I get the same mistake. As below, I copy and paste the fault:

Dim Return As Long =And64Bits(0x1FFFC0000000,0x1FFFC0000000)
javac 1.6.0_24
shell\src\anywheresoftware\b4a\samples\bluetooth\main_subs_0.java:658: integer number too large: 1fffc0000000
_return = _and64bits(BA.numberCast(long.class, 0x1fffc0000000),BA.numberCast(long.class, 0x1fffc0000000));Debug.locals.put("Return", _return);Debug.locals.put("Return", _return);


I can't understand why the fault is talking about an integer number when I define only long datatype
 
Upvote 0

MLDev

Active Member
Licensed User
Longtime User
Hexadecimal notation is limited to integers. Try:

B4X:
Log(And64Bits(35183298347008, 35183298347008))
 
Upvote 0
Top