Greg Woodhouse wrote: >if X and Y represent (unsigned) decimal > integers, does GT.M provide an easy (and efficient) means of carrying > out bitwise operations on X and Y). For example, if X = 12 (binary > 1100)and Y = 49 (binary 110001), I'd expect that > > X bitwise-or Y = 61 (binary 111101) > > > 1 1 0 0 0 1 > 1 1 0 0 > ------------ > 1 1 1 1 0 1
Bit functions in GT.M appear very similar to those in DTM, and I assume, in Cache'. They are oriented around doing fast tests on very long bitstrings. These might be stored in a database as a means of representing membership of data records in various sets. According to the GT.M programmer documentation, bitstrings have a leading byte that gives the count of invalid bits at the end of the bitstring. As Bhaskar indicates, there is no automatic conversion of numerics to bitstrings. There are examples of use in the documentation that show a couple of different conversion methods. The functions are $ZBITAND(), $ZBITCOUNT(), $ZBITFIND(), $ZBITGET(), $ZBITLEN(), $ZBITNOT(), $ZBITOR(), $ZBITSET(), $ZBITSTR(), $ZBITXOR(). $ZBITSTR(bits,state) will create a bitstring with a given number of bits all set to true or false according to the value of state. The maximum number of bits is 253,952. $ZBITSTR(8,0)=$c(0,0) $ZBITSTR(16,0)=$c(0,0,0) $ZBITSTR(24,0)=$c(0,0,0,0) $ZBITSTR(32,0)=$c(0,0,0,0,0) ... If X is an integer in the range 0-255 (8-bit value) then one way of converting X to a bitstring would be $c(0,X). ;testing zbit* functions s x=12,y=49 s bitstr=$zbitOr($c(0,x),$c(0,y)) zwr bitstr bitstr=$C(0)_"=" w $a(bitstr,2) 61 --------------------------------------- Jim Self Systems Architect, Lead Developer VMTH Computer Services, UC Davis (http://www.vmth.ucdavis.edu/us/jaself) ------------------------------------------------------- SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf _______________________________________________ Hardhats-members mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/hardhats-members
