Subj : Re: Reversing a number To : comp.programming From : Antoon Pardon Date : Thu Sep 15 2005 03:10 pm Op 2005-09-15, Willem schreef : > Gerry wrote: > ) 14 is not a number - the number represented by the strings 14 (base > ) 10), 1110 (base 2) and 11111111111111 (unary) is a number. If the > ) problem is to calculate '41' given 14 the only meaning of this problem > ) is to convert this number to a base-10 string representation and > ) reverse it, then convert back to a number. > > I disagree. The problem only states what the end-result should be and > does NOT specify how it should be done. The statement of the end result implies that is about numerals, strings representations of numbers, and not about numbers itself. > Of course, if you state the > problem as such, then all algorithms that solve it will seem to > 'obscurely' do what you described. > > ) This is what your algorithm does, but in an obscure fashion. > ) > ) We could explicitly do the conversions, with a string reversal in the > ) middle, using arithmetic. All your algorithm does is mix the three > ) operations together, which does save some memory registers but is > ) hardly simpler in any real sense. > > It is simpler in the very real sense that no strings are involved. > ('strings' as defined by the programming language.) > The only thing that is involved is digits, and base-10 representation. base-10 representation says it all, this is about the representations in a particular base. It is not about the numbers themselves. > The algorithm described (it's not my algorithm by the way) extracts > base-10 digits from one number and injects it into another, one by one. > That's all it does. No strings. Extracting base-10 digits is conceptually working with strings. That you keep the digits as a number because that works easier changes nothing about that. Digits is what numerals in particular notations have. Numbers don't have digits. Yes your algorithm works with numbers, but when you explain what it does you are constantly reffering to numeral concepts and not to number concepts, thus betraying that conceptually you are working with strings. -- Antoon Pardon .