Hi
Im converting some c++ code to vb ( basically i dont know c++ well enough to do it in c++ )
and ive come to this line
x = (x<<13) ^ x;
where x is a 32bit integer ( long in vb )
Does anybody know how to convert this into a vb statement?
Thanks.
Printable View
Hi
Im converting some c++ code to vb ( basically i dont know c++ well enough to do it in c++ )
and ive come to this line
x = (x<<13) ^ x;
where x is a 32bit integer ( long in vb )
Does anybody know how to convert this into a vb statement?
Thanks.
Should be correct.Code:Dim x As Long
x = (x * 26) Xor x
Z.
A bit shift should be translated as *2^n, but that is really slow. If the shift is fixed you can calculate it first:
VB Code:
x = (x * 8192) Xor x 'x = (x<<13) ^ x;
Duh, what was I thinking? -.-;;Quote:
Originally posted by twanvl
A bit shift should be translated as *2^n, but that is really slow. If the shift is fixed you can calculate it first:
VB Code:
x = (x * 8192) Xor x 'x = (x<<13) ^ x;
Z.
Still far slower than a shift, but that cannot be helped. VB simply doesn't know shifts.
Makes me glad that almost every C/C++ compiler out there automatically interprets that kinda stuff as a shift - even if you code it as multiplication.
makes me sick. They didn't include shifts in VB because they thought programmers shouldn't be concerned with lowlevel issues, and I agree with them, we'd all be stuck with machine code otherways. A programming language should be abstract and independent of the machine.