Hello There,
I am having terrrible trouble getting my head round certain bits of C - namely compound operators.
I have been programming in BASIC since the early 80s and then moved on to Turbo Pascal in the late 80s, then coding in ASP/HTML / Visual BASIC since the mid 1990s.
I cam also tinker in Javascript, but have come acrosss a need to convert a program from C to Basic.
Most of it I have done, but there are one or two routines which I cannot get my head around, no matter how hard I try...
Can anyone shed any light ... I need to convert the following from C to VB / Basic.
long XCH;
int Xoptions;
void mybits (short bit); {
printf ( (XCH & (1L<<bit))!=0);
XCH |= (1L<<bit) );
XCH &=~ (1L<<bit );
}
void myoption (int option); {
Xoptions |= option;
Xoptions &=~ option;
XOptions ^= option;
}
I have looked around and I know voids are like subroutines which I am passing parameters through to (bit and option), and I know that I have two global variables set up (XCH and XOptions), but I cannot get my head around the compound operators ... I think SHL and SHR come into it somewhere ... can anyone point me in the right direction to understand the above by replying with a VB equivalent of the above statements?
Many thanks.
Steve.
Last edited by badkarma; 02-26-2008 at 07:39 PM.
Found this ...
Bitwise operation - Wikipedia, the free encyclopedia
which seems to explain alll... woohoo
so I guess I can use SHL SHR OR XOR And etc in BASIC
I guess I have answered my own question ... hope this is useful to others
xxx
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks