On Wed, 6 Dec 2017 16:23:16 +0100, Terje Mathisen   
    wrote:   
   >...   
   >It looks like you want both the decimal number and the check for it   
   >being a palindrome, right?   
   >   
   >Otherwise, if you justneed the test for palindromicity, and most inputs   
   >will not be so, then you want a faster test, right?   
   >...   
   Right! I mainly wanted to test the Reciprocal for 10, that's why I go   
   through all the digits (I'm not quite sure whether I interpreted the   
   maximum possible number right from the text). For the test for   
   palindromicity it is of course a brute force approach.   
   >...   
   >Start by using the number of set bits to estimate how many digits you   
   >will have, then extract the bottom and top digits with reciprocal muls   
   >(using lookup table reciprocals) and compare them.   
   >...   
   That would certainly be faster, but I would rather think along the   
   lines of doing a log10 with the FPU to get the exact number of digits   
   before comparing the top and bottom digits.   
   >...   
   >If you need both returns then the best you can do is to use a 64-bit   
   >version of the algorithm I first posted maybe 20 (?) years ago which   
   >splits the number into two parts, scales them into n.nnnnnn format and   
   >then extract the digits in parallel starting from the top and using LEA   
   >to multiply by 5 between each digit.   
   >...   
   Would be interesting to see that code!   
   --   
   aen   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|