I, uh....honestly can't believe we don't have this one yet.
Write two functions or programs that:
- Convert from decimal to percentage
- Convert from percentage to decimal
You may also write a single program that does both of the above.
Percentages must be taken and returned with a percent sign. (In many languages, this means they will be strings.) They may be integers or floating point numbers.
Decimals are just floating point numbers.
You do not need to handle rounding errors involving very large or very small floating point numbers.
In cases where the numbers are integers (such as 56.0) you may return
56.0. (This is intended to make I/O more flexible.)
0.0% <-> 0.0 100.0% <-> 1.0 56.0% <-> 0.56 123.0% <-> 1.23 -11.0% <-> -0.11 -214.91% <-> -2.1491
This is code-golf, so the shortest answer in each language wins. If you write two separate programs, add their sizes for your score.