Converts a decimal number to binary representation (base 2).

const bin1 = Chalkboard.numb.toBinary(10); // Returns "1010"
const bin2 = Chalkboard.numb.toBinary(10, true); // Returns "0b1010"
  • Parameters

    • num: number

      The decimal number

    • Optionalprefix: boolean = false

      Whether to include "0b" prefix (optional, defaults to false)

    Returns string