putting zeros to certain number of leading bits in a number in VB

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does anyone know how to make sure that the first 48 bits are zeros in int64
value in VB. Basically what the operation I’m trying to achieve is the
equivalent of the following in C#

C# version:
long lngValue;
long result;

lngValue=8978474837228;

result = (lngValue >>48)& 0x000000000000FFFF;
 
Cherif said:
Does anyone know how to make sure that the first 48 bits are zeros in int64
value in VB. Basically what the operation I'm trying to achieve is the
equivalent of the following in C#

C# version:
long lngValue;
long result;

lngValue=8978474837228;

result = (lngValue >>48)& 0x000000000000FFFF;

"Bitwise And" uses the same keyword as "Logical And" in VB: And

So

Result = (lngValue >> 48) And 65535

(some have, in the past, disagreed with me about "And" being the
"Logical And" keyword, stating that AndAlso is the "Logical And". The
difference is whether short-circuit evaluation occurs, but since that
is not a requirement from a logical perspective, it's more true to
state that both And and AndAlso are "Logical And".)

Damien
 
Hi Damien How did you came up with the number 65535
Is there a place where I can get more info

Thanks for your help
 
Cherif said:
Hi Damien How did you came up with the number 65535
Is there a place where I can get more info

Thanks for your help
To be honest, I don't do constants very often. I also switch between C#
and VB. I couldn't remember the VB way of saying "this is a hex
constant" (think it might be prefix with "&"), so I just converted your
000000000000FFFF to decimal :-|

Hope it didn't confuse you too much,

Damien
 
Back
Top