* Converts a character or number to its binary representation. * * @param {char|number} c * @param {number} [length=8] - The width of the resulting binary number. * @returns {string} * * @example * // returns "01101110" * Utils.bin("n"); * * // retur
(c, length=8)
| 162 | * Utils.bin(110); |
| 163 | */ |
| 164 | static bin(c, length=8) { |
| 165 | c = typeof c == "string" ? Utils.ord(c) : c; |
| 166 | return c.toString(2).padStart(length, "0"); |
| 167 | } |
| 168 | |
| 169 | |
| 170 | /** |