# NewGamePhysics.Utilities.BitCount Class Reference

Counts the bits in integer values. More...

List of all members.

## Public Member Functions
| BitCount ()
| Constructor which generates a bit count lookup array.
int | FastBitcount (ushort testThis)
| Find the number of bits in the parameter ushort.
int | FastBitcount (short testThis)
| Find the number of bits in the parameter short.
int | FastBitcount (uint testThis)
| Find the number of bits in the parameter uint.
int | FastBitcount (int testThis)
| Find the number of bits in the parameter int.
int | FastBitcount (ulong testThis)
| Find the number of bits in the parameter long.
int | FastBitcount (long testThis)
| Find the number of bits in the parameter int.
int | FastBitcount (double testThis)
| Find the number of bits in the parameter double.

## Detailed Description

Counts the bits in integer values.

Definition at line 13 of file BitCount.cs.

## Constructor & Destructor Documentation

NewGamePhysics.Utilities.BitCount.BitCount | ( |  | ) |

Constructor which generates a bit count lookup array.

Definition at line 25 of file BitCount.cs.

    00026         {
    00027             // Initialize cache
    00028             bitcountCache = new byte[65536];
    00029             for (int i = 0; i < 65536; i++)
    00030             {
    00031                 bitcountCache[i] = SparseBitcount(i);
    00032             }
    00033         }

## Member Function Documentation

int NewGamePhysics.Utilities.BitCount.FastBitcount | ( | double | testThis | ) |

Find the number of bits in the parameter double.

Parameters:

  | testThis | The number to count the bits of.

Returns:
  The number of bits in the parameter.

Definition at line 104 of file BitCount.cs.

    00105         {
    00106             // Translate the double into a 64 bit long.
    00107             long testThisBits = BitConverter.DoubleToInt64Bits(testThis);
    00108             return FastBitcount((ulong)testThisBits);
    00109         }

int NewGamePhysics.Utilities.BitCount.FastBitcount | ( | long | testThis | ) |

Find the number of bits in the parameter int.

Parameters:

  | testThis | The number to count the bits of.

Returns:
  The number of bits in the parameter.

Definition at line 94 of file BitCount.cs.

    00095         {
    00096             return FastBitcount((ulong)testThis);
    00097         }

int NewGamePhysics.Utilities.BitCount.FastBitcount | ( | ulong | testThis | ) |

Find the number of bits in the parameter long.

Parameters:

  | testThis | The number to count the bits of.

Returns:
  The number of bits in the parameter.

Definition at line 81 of file BitCount.cs.

    00082         {
    00083             return bitcountCache[(testThis >> (0 * 16)) & 65535L] +
    00084                    bitcountCache[(testThis >> (1 * 16)) & 65535L] +
    00085                    bitcountCache[(testThis >> (2 * 16)) & 65535L] +
    00086                    bitcountCache[(testThis >> (3 * 16)) & 65535L];
    00087         }

int NewGamePhysics.Utilities.BitCount.FastBitcount | ( | int | testThis | ) |

Find the number of bits in the parameter int.

Parameters:

  | testThis | The number to count the bits of.

Returns:
  The number of bits in the parameter.

Definition at line 71 of file BitCount.cs.

    00072         {
    00073             return FastBitcount((uint)testThis);
    00074         }

int NewGamePhysics.Utilities.BitCount.FastBitcount | ( | uint | testThis | ) |

Find the number of bits in the parameter uint.

Parameters:

  | testThis | The number to count the bits of.

Returns:
  The number of bits in the parameter.

Definition at line 60 of file BitCount.cs.

    00061         {
    00062             return bitcountCache[(testThis >> (0 * 16)) & 65535] +
    00063                    bitcountCache[(testThis >> (1 * 16)) & 65535];
    00064         }

int NewGamePhysics.Utilities.BitCount.FastBitcount | ( | short | testThis | ) |

Find the number of bits in the parameter short.

Parameters:

  | testThis | The number to count the bits of.

Returns:
  The number of bits in the parameter.

Definition at line 50 of file BitCount.cs.

    00051         {
    00052             return FastBitcount((ushort)testThis);
    00053         }

int NewGamePhysics.Utilities.BitCount.FastBitcount | ( | ushort | testThis | ) |

Find the number of bits in the parameter ushort.

Parameters:

  | testThis | The number to count the bits of.

Returns:
  The number of bits in the parameter.

Definition at line 40 of file BitCount.cs.

    00041         {
    00042             return bitcountCache[testThis];
    00043         }

The documentation for this class was generated from the following file:

- C:/Users/Andreas Schiffler/Desktop/SVN/NewGamePhysics/NewGamePhysics/Utilities/BitCount.cs