The task is to convert a string representing a number in decimal (base 10) representation to duodecimal (base 12). The input is thus a string, the output should be printed.
The input number can be positive and negative, can be integer or rational. The decimal and duodecimal representations will have a finite number of digits after the (duo)decimal point.
The digits for duodecimal should be 0-9, a, b.
The output should not contain trailing zeroes after the duodecimal point and no leading zeroes before the duodecimal point. The duodecimal point should only be printed if the number is non-integer.
examples
input 400 -> output 294
input 14 -> output 12
input 1498 -> output a4a
input -11 -> output -b
input 11.875 -> output b.a6
counter examples
not okay are outputs like "-001a", "00b.300", "1.050".
EDIT: additional assumptions
- the number can be represented exactly as float
- there are overall less than 7 digits (excluding a minus and a duodecimal point) needed to represent the result.
a
andb
, the output had to use the duodecimal digits↊
and↋
. This would have at least helped with the boring built-in answers \$\endgroup\$