Let N(x) be the value of the decimal numeral with the fewest significant digits
such that x is the
As a baseline: In Java, the
Double.toString() provides the N(x) function described in the question, returning its value as a numeral. One could take the strings for a and b, subtract them with the elementary-school method, and convert the resulting string to
This demonstrates solving the problem is quite feasible using existing library routines. This leaves the task of improving the solution. I suggest exploring:
doublevalues), subtract them, and divide by the power of ten?
b-aor some simple expression can be quickly rounded to something near a decimal numeral, bypassing the code that would be necessary for harder cases? E.g., could we prove that for numbers within a certain range,
(round(10000*b)-round(10000*a))/10000always produces the desired result?