We have a real number that we want to approximate with as few characters as
possible. We require that either the absolute
error or the relative error must be strictly less than 10^-k. The absolute
error is the absolute difference between the values of the shortened version
and the original.
The relative error is the absolute error divided by the absolute value of
the original (or is taken to be infinity if the original is 0).
We want the shortened version expressed as a string of digits, possibly with
a decimal point. The original number is given to us in that form.
Given k and number,
return the number of characters in the shortest approximation.
|