Subj : Re: Reversing a number To : comp.programming From : Antoon Pardon Date : Fri Sep 16 2005 11:56 am Op 2005-09-16, Willem schreef : > Antoon wrote: > ) Op 2005-09-15, Willem schreef : > )> Lemme ask you a question: Suppose I have an algorithm that solves the > )> following problem: > )> > )> Return (as a number) the base-10 digits of the input number, repeated > )> twice. (That is: f(123) = 123123, f(15) = 1515, f(100200) = 100200100200) > )> > )> Would you claim that that algorithm involves strings ? > ) > ) Of course, because this is essentially a string problem. You turn a > ) string into the string concatenated with itself. You have just > ) limited the problem space to specific strings and use numbers to > ) represent those strings. > > For your information, this is the algorithm: > > f(x) = x * (10^trunc(log10(x)+1)+1) > No strings. Your claim that 'the problem definition involves strings' > implies automatically that 'the solution involves strings' is unfounded. > Unless you claim that these numbers are actually strings (see below). You are working with number coded strings. > ) A numeral is a string. The fact that you working with numerals > ) implies that you are working with strings. > > I'm not working with numerals. The algorithm only works with digits > and numbers. > > ) Just because you algorithm codes your strings as numbers, doesn't > ) mean it doesn't use strings. > > That's a meaningless claim, because with such reasoning you can claim > somebody is using just about anything. What someone is using IMO, depends on how he is manipulating it conceptually. Because otherwise you can always claim he only uses numbers, because all that is used on the computer finally gets translated into numbers. If you want to, you can see strings as 256-base numerals with some computer character sets as the digits and all string manipulations can then be translated into number manipulations. > And you can also claim that any > algorithm whatsoever uses strings. I find that meaningless, and would > rather be able to say 'this algorithm uses strings, and that algorithm > does not'. But is it a different algorith because the coding is different? If you have an algirithm that essentially picks the last character from one string and sticks it at the end of another string, does the identity of this algorithm depend on the coding used for these strings. Is it a different algorithm if the strings are coded as byte arrays vs numbers in a bignum library that are interpreted as 256-base numerals?. > ) I have some code that encodes small sets of cardinal numbers > ) as numbers itself with bit-operators. Are you claiming that > ) whenever I use this code to work with small-sets I am not > ) using sets, but cardinals, because that is how they are coded? > > It would have been easier if you (or whoever you stepped in for) would have > answered 'yes' to my question way back 'are you claiming that numbers are > actually strings'. The answer is no, but either can be coded into the other one. -- Antoon Pardon .