Next: ncols() Up: MacAnova Help File Previous: nameof()   Contents

nbits()

Usage:
nbits(x), where x consists of 1 or more integers between 0 and
  4294967295



Keywords: operations, transformations, glm
                                  Usage
nbits(x), where x is an integer with value between 0 and 4294967295
(2^32-1), computes the number of non-zero bits in the binary
representation of x.  For example, nbits(123455) is 11 since 123455 has
binary representation 00000000000000011110001000111111b.

If x is not an integer or x < 0 or x > 4294967295, a warning message is
printed and the result is set to MISSING.

If x is a REAL vector, matrix or array or a structure all of whose
components are REAL, nbits(x) is a variable or structure of the same
size and shape as x, each element of which is the number of bits in the
corresponding element of x.

nbits() is useful with the output of modelinfo(bitmodel:T).

                                Examples
Examples:
After anova("y=(a+b)^2 + ((a+b)^2).x",silent:T) the following commands
compute the number of variables or variates in term 5 and in all terms:

  Cmd> nvars5 <- sum(vector(nbits(modelinfo(bitmodel:T)[5,]))); nvars5
  (1)           2

  Cmd> vector(sum(nbits(modelinfo(bitmodel:T)')),labels:TERMNAMES[-8])
    CONSTANT           a           b         a.b         a.x         b.x
       a.b.x
           0           1           1           2           2           2
           3

                            Cross references
See also topics 'bit_ops', modelinfo().


Gary Oehlert 2006-01-30