Ones

Description:              This function returns the number of bits set in an integer number.

Returns:                    Numeric

Usage:                       Script or Steady State

Format:                      Ones(Value)

Parameters:             Value    { numeric }  { required }  { no default }

                                      Any numeric expression.

Comments:               Value must be a valid number and is truncated to an integer; the number of bits set is returned.

Examples:

a = Ones(0b010110);

b = Ones(0b001100);

c = Ones(2.3);

The values of a, b and c will be 3, 2 and 1 respectively.

See Also:

Bit | SetBit