Function isBitOn

  • Checks whether the bit at the specified position in a number is set (1).

    Returns

    true if the bit at position k is 1, otherwise false.

    Example

    isBitOn(0b1010, 1); // → true  (bit 1 is set)
    isBitOn(0b1010, 0); // → false (bit 0 is clear)

    Remarks

    • Works with any 32-bit integer representable in JavaScript.
    • Does not modify the original number.

    Parameters

    • n: number

      The number to check.

    • k: number

      Zero-based bit position to check (0 = least-significant bit).

    Returns boolean

Generated using TypeDoc