#C13741. Decimal to Binary Conversion
Decimal to Binary Conversion
Decimal to Binary Conversion
Given an integer \(n\) (which can be positive, negative, or zero), your task is to convert it into its binary representation as a string. The conversion must be done manually without using built-in functions like bin()
in Python.
For a negative number, prefix the binary representation with a minus sign (-
). For example, if \(n = -18\), the output should be "-10010". If \(n = 0\), simply output "0". The binary representation should not have any unnecessary leading zeros.
inputFormat
The input consists of a single integer \(n\) provided via standard input.
Example:
12
outputFormat
Output the binary string representation of the given integer \(n\) through standard output.
Example:
1100## sample
12
1100