![]() |
Bit manipulation
Hi all,
Does VBA (Excel 97) have bit manipulation functions - shiftleft/right etc? I couldn't find anything that looked promising. Tony |
Bit manipulation
Nope... nothing direct. You could write a program in C/C++ and call that
program through the shell command. That is probably your best option... HTH "Tony" wrote: Hi all, Does VBA (Excel 97) have bit manipulation functions - shiftleft/right etc? I couldn't find anything that looked promising. Tony |
Bit manipulation
Or create your own
Function BitShiftRight(Val As Long, NumBits As Integer) As Long BitShiftRight = Val * (2 ^ NumBits) End Function Function BitShiftLeft(Val As Long, NumBits As Integer) As Long BitShiftLeft = Val \ (2 ^ NumBits) End Function -- HTH RP (remove nothere from the email address if mailing direct) "Jim Thomlinson" wrote in message ... Nope... nothing direct. You could write a program in C/C++ and call that program through the shell command. That is probably your best option... HTH "Tony" wrote: Hi all, Does VBA (Excel 97) have bit manipulation functions - shiftleft/right etc? I couldn't find anything that looked promising. Tony |
Bit manipulation
That is good for a shift but any idea how you would get any of the other
bitwise operators? I still say you go with C/C++. As an aside to do a bit shift you should just be able to multiply or divide by 2 which in base 2 will functionally shift the bits? I think... I am sure you will let me know Bob... :) "Bob Phillips" wrote: Or create your own Function BitShiftRight(Val As Long, NumBits As Integer) As Long BitShiftRight = Val * (2 ^ NumBits) End Function Function BitShiftLeft(Val As Long, NumBits As Integer) As Long BitShiftLeft = Val \ (2 ^ NumBits) End Function -- HTH RP (remove nothere from the email address if mailing direct) "Jim Thomlinson" wrote in message ... Nope... nothing direct. You could write a program in C/C++ and call that program through the shell command. That is probably your best option... HTH "Tony" wrote: Hi all, Does VBA (Excel 97) have bit manipulation functions - shiftleft/right etc? I couldn't find anything that looked promising. Tony |
Bit manipulation
Give us a break Jim, he only mentioned shifting :-)
Which others are you thinking of, VBA has AND, OR, XOR, IMP and so on? -- HTH RP (remove nothere from the email address if mailing direct) "Jim Thomlinson" wrote in message ... That is good for a shift but any idea how you would get any of the other bitwise operators? I still say you go with C/C++. As an aside to do a bit shift you should just be able to multiply or divide by 2 which in base 2 will functionally shift the bits? I think... I am sure you will let me know Bob... :) "Bob Phillips" wrote: Or create your own Function BitShiftRight(Val As Long, NumBits As Integer) As Long BitShiftRight = Val * (2 ^ NumBits) End Function Function BitShiftLeft(Val As Long, NumBits As Integer) As Long BitShiftLeft = Val \ (2 ^ NumBits) End Function -- HTH RP (remove nothere from the email address if mailing direct) "Jim Thomlinson" wrote in message ... Nope... nothing direct. You could write a program in C/C++ and call that program through the shell command. That is probably your best option... HTH "Tony" wrote: Hi all, Does VBA (Excel 97) have bit manipulation functions - shiftleft/right etc? I couldn't find anything that looked promising. Tony |
Bit manipulation
shiftleft/right etc? How about etc... And those operators you mention are
not bitwise are they. If they can be used bitwise let me know... That would be kinda cool... :) "Bob Phillips" wrote: Give us a break Jim, he only mentioned shifting :-) Which others are you thinking of, VBA has AND, OR, XOR, IMP and so on? -- HTH RP (remove nothere from the email address if mailing direct) "Jim Thomlinson" wrote in message ... That is good for a shift but any idea how you would get any of the other bitwise operators? I still say you go with C/C++. As an aside to do a bit shift you should just be able to multiply or divide by 2 which in base 2 will functionally shift the bits? I think... I am sure you will let me know Bob... :) "Bob Phillips" wrote: Or create your own Function BitShiftRight(Val As Long, NumBits As Integer) As Long BitShiftRight = Val * (2 ^ NumBits) End Function Function BitShiftLeft(Val As Long, NumBits As Integer) As Long BitShiftLeft = Val \ (2 ^ NumBits) End Function -- HTH RP (remove nothere from the email address if mailing direct) "Jim Thomlinson" wrote in message ... Nope... nothing direct. You could write a program in C/C++ and call that program through the shell command. That is probably your best option... HTH "Tony" wrote: Hi all, Does VBA (Excel 97) have bit manipulation functions - shiftleft/right etc? I couldn't find anything that looked promising. Tony |
Bit manipulation
On Mon, 14 Mar 2005 15:01:02 -0800, "Jim Thomlinson"
wrote: AND, OR, XOR, IMP Yes, they ARE bitwise, as are NEG, and EQV. But as for trying to implement shifts using arithmetic, you have to be careful re shifting into or out of the sign bit. |
Bit manipulation
"Myrna Larson" wrote in message ... On Mon, 14 Mar 2005 15:01:02 -0800, "Jim Thomlinson" wrote: AND, OR, XOR, IMP Yes, they ARE bitwise, as are NEG, and EQV. But as for trying to implement shifts using arithmetic, you have to be careful re shifting into or out of the sign bit. Agreed, and my example was simplistic, but again it can be done. |
Bit manipulation
I see a typo (again!): it's NOT, not NEG.
On Tue, 15 Mar 2005 10:05:08 -0000, "Bob Phillips" wrote: "Myrna Larson" wrote in message .. . On Mon, 14 Mar 2005 15:01:02 -0800, "Jim Thomlinson" wrote: AND, OR, XOR, IMP Yes, they ARE bitwise, as are NEG, and EQV. But as for trying to implement shifts using arithmetic, you have to be careful re shifting into or out of the sign bit. Agreed, and my example was simplistic, but again it can be done. |
All times are GMT +1. The time now is 02:07 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com