Fred,
Just a small thing. . .
maybe it's a platform dependent thing, but my learning has been:
16 bits - a halfword
32 bits - a word
64 bits - a doubleword
Cheers
Jim N
>>Fred, what I mean was the practical aspects of using bitwise functions in applications. I have searched the UT files but couldn't find any info on these functions. Just wanted to know how to use them and their benefits and their limitations. Tks
>
>Biwise functions are not used as much now as they were in the past. Bitwise functions could be used to store many yes/no type answers in a more condensed manor, 1 answer per bit. Bit math is based on binary values 0/1 or raising a 2 to a power (2^0=1, 2^1=2, 2^2=4, 2^3=8, 2^4=16, etc.)
>Terminology:
>Bit - a single position
>Nyble - a series of 4 bits
>Byte - a series of 8 bits
>Word - a series of 16 bits
>DoubleWord - a series of 32 bits
>Hexadecimal Numbers - base 16 numbers 0 to F. Each nyble is represented by a single Hex digit (0-F), and each byte is represented by 2 Hex digits. VFP represents hex by prefixing a hex value with "0x" and can translate a decimal value to hex by TRANSFORM(Decimal,"@0")
>
>Say you had a 32 bit integer (4 bytes) numbered 31-0
>
>|3 2|2 1|1 | |
>|1......4|3......6|5......8|7......0|
> -------- -------- -------- --------
> 00000000 00000000 00000000 00000001 = 1 decimal = 2^0
> 00000000 00000000 00000000 00000010 = 2 decimal = 2^1
> 00000000 00000000 00000000 00000100 = 3 decimal = 2^2
>...
> 10000000 00000000 00000000 00000000 = 2147483648 decimal = 2^31
>
>Now you can manipulate individual bits by performing AND's to reset, OR's to set a bit.
>Say you wanted to "set" bit 8. You would do:
> 00010000 10000000 11100000 00011000 = 276881432 decimal
> OR
> 00000000 00000000 00000001 00000000 = 256 decimal
> Result
> 00010000 10000000 11100001 00011000 = 276881688 decimal
>
>An OR is a bit by bit comparison of the two values and if either bit is 1, the result is 1. An OR is the same as adding the values together.
>
>In VFP you could do:
>nResult = BITOR(0x1080e018,0x00000100)
>nResult = BITSET(0x1080e018,8)
>
>
>Say you wanted to "reset" bit 8. You would do:
> 00010000 10000000 11100001 00011000 = 276881688 decimal
> AND
> 11111111 11111111 11111110 11111111 = 4294967039 decimal
> Result
> 00010000 10000000 11100000 00011000 = 276881432 decimal
>
>An AND is a bit by bit comparison of the two values and if both bits are 1, the result is 1, 0 where they aren't both 1.
>In VFP you could do:
>nResult = BITAND(0x1080e118,0xfffffeff)
>nResult = BITCLEAR(0x1080e118,8)
>
>
>Additional functions:
>An XOR is a bit by bit comparison of the two values and if both bits match, the result is 1.
>ANDs, ORs, and XOR's can manipulate more than 1 bit at a time.
>
>Shifting is moving the bit pattern to the left or right.
>
>Not reverses the bit patterns.
>
>VFP has functions:
>BITAND(), BITCLEAR( ), BITLSHIFT( ), BITNOT( ), BITOR( ), BITRSHIFT( ), BITTEST( ), BITXOR( )
>
>These functions are useful for manipulating hardware, or for setting/resetting flag values for Windows API type calls.
>
>I don't know if this is what you're looking for or not, but maybe someone will benefit from this.