Sets (changes to 1) the bit at the specified position in a number.
The original number is not mutated; a new number is returned with the bit set.
A new number equal to n with bit k set.
n
k
setBit(0b1001, 1); // → 0b1011 (sets bit 1)setBit(0b0111, 3); // → 0b1111 (sets bit 3)
The original number whose bit is to be set.
Zero-based bit position to set (0 = least-significant bit).
Generated using TypeDoc
Sets (changes to 1) the bit at the specified position in a number.
The original number is not mutated; a new number is returned with the bit set.
Returns
A new number equal to
nwith bitkset.Example
Remarks
kis affected; all other bits remain unchanged.