UNPKG

convert2base

Version:

Project developed to perform basic binary conversions involving binary, octal, decimal and hexadecimal numbers.

11 lines (7 loc) 401 B
import { convertDecimalToBinaryRecursive } from '../../utils/decimal/decimal-to-binary-util'; import { validateDecimalNumber } from '../../validators/decimal-number-validator'; export const decToBin = (decimalNumber: string): string => { validateDecimalNumber(decimalNumber); const binaryNumber = convertDecimalToBinaryRecursive(parseInt(decimalNumber)); return binaryNumber || '0'; };