Subj : Re: Reversing a number To : comp.programming From : Gerry Quinn Date : Wed Sep 14 2005 11:43 am In article , willem@stack.nl says... > Gerry wrote: > ) Essentially, that IS the problem specification. It is, after all, the > ) simplest interpretation of the mathematical operation of 'reversing a > ) number', that is to say, determining an number that can be represented > ) in base-10 as the string of digits that is the reverse of the string > ) representing the original number. > ) > ) How would you explain in detail the problem, without reference to > ) strings? > > Why would I *want* to explain the problem without reference to strings ? > That the prolem definition needs strings to be able to explain the > requirements does *not* imply that the solution necessarily involves > strings. > > The problem definition is simply to take a number and return the result > of reversing that number in base-10 notation. > > If you want to argue that 'base-10 notation' involves strings, go right > ahead, I won't argue with that. > > But the solution (iteratively multiplying the output by ten, dividing > the input by ten and adding the remainder to the output until the input > becomes zero) does not involve strings directly. It inputs a number and > outputs a number. No strings. Unless you wish to claim that a number is > secretly a string, of course. Not directly, but conceptually it is all about manipulating the base-10 string representation. What are easily comprehensible in these terms turn into kludgy numeric operations instead. When I take x % 10, I am determining a value that encodes a digit in the string representation. The right end of the string, as I look at the string representing the number. - Gerry Quinn .