Subj : Re: Reversing a number To : comp.programming From : Willem Date : Thu Sep 15 2005 11:02 am 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. 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. 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. ) And, as can be seen, whether it requires fewer statements depends on ) the language used. It requires fewer basic operations in any case, because languages that can do such conversions do a lot of work under the hood. SaSW, Willem -- Disclaimer: I am in no way responsible for any of the statements made in the above text. For all I know I might be drugged or something.. No I'm not paranoid. You all think I'm paranoid, don't you ! #EOT .