Here is an interesting one for all you bit flipping coders out there...
_TOGGLEBIT
SYNTAX result = _TOGGLEBIT(numericalVariable, numericalValue)
Usage: For cross breeding elephants and rhinos. What's that good for? Eleph-i-no!
Okay, I know bit-flipping can be used somehow to detect a hardware malfunction in a Windows operating system. I would imagine encryption would be another practical use. I also did some reading on using bit-flipping as an alternative to doing string math, but that was a very involved process, so I have no work created to demonstrate how that would be accomplished.
What I can easily see if we flip the first bit, we can get a 0 or 1, which is good for a toggle function.
Now the easiest method to create your own toggle for a program has been demonstrated in this forum numerous times...
toggle = 1 - toggle Mark posted about that one months ago.
So using toggle = 1 - toggle we start out with toggle = 0, hence 1 - 0 = 1. Loop again and 1 - 1 = 0
Now we can accomplish the exact same toggle effect with _TOGGLEBIT, as follows...
So maybe this example will goad Steve a "bit" to elaborate on some of his experiences with _TOGGLEBIT. Also, I'd love to hear some comments from @jack about bit-flipping, and his experience with coding decfloat.
Pete
_TOGGLEBIT
SYNTAX result = _TOGGLEBIT(numericalVariable, numericalValue)
Usage: For cross breeding elephants and rhinos. What's that good for? Eleph-i-no!
Okay, I know bit-flipping can be used somehow to detect a hardware malfunction in a Windows operating system. I would imagine encryption would be another practical use. I also did some reading on using bit-flipping as an alternative to doing string math, but that was a very involved process, so I have no work created to demonstrate how that would be accomplished.
What I can easily see if we flip the first bit, we can get a 0 or 1, which is good for a toggle function.
Now the easiest method to create your own toggle for a program has been demonstrated in this forum numerous times...
toggle = 1 - toggle Mark posted about that one months ago.
So using toggle = 1 - toggle we start out with toggle = 0, hence 1 - 0 = 1. Loop again and 1 - 1 = 0
Now we can accomplish the exact same toggle effect with _TOGGLEBIT, as follows...
Code: (Select All)
DIM a AS INTEGER ' Also avilable are _INTEGER64, LONG, _UNSIGNED, and _BYTE,
DO
DO
SELECT CASE a
CASE 0
PRINT " Steve is good...";
CASE 1
PRINT " Pete is better!": PRINT
END SELECT
SLEEP
a = _TOGGLEBIT(a, 0)
mykey$ = INKEY$
LOOP UNTIL mykey$ = CHR$(9) OR mykey$ = CHR$(27)
PRINT
FOR i = 0 TO 15
PRINT i; _TOGGLEBIT(a, i)
NEXT
PRINT
LOOP UNTIL mykey$ = CHR$(27)
So maybe this example will goad Steve a "bit" to elaborate on some of his experiences with _TOGGLEBIT. Also, I'd love to hear some comments from @jack about bit-flipping, and his experience with coding decfloat.
Pete