Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 1
    thanks, these are good tips, just one question, the base is constant and it is actually 10, but how do you replace division by a constant with multiplication ? Regarding the lookup tables, I don't understand well, you mean lookup a 'byte', not 'bit' ? What is the puprose of 'vector add'? And, what is the resulting number 131200 mean? Commented Oct 25, 2011 at 19:50
  • Oops, I messed up my example. Will fix. Commented Oct 25, 2011 at 19:54
  • My example is converting an integer 0x00020080 to decimal. You can convert each byte (or whatever subunit you like) with a lookup table, then do the addition of these components once it's in decimal (akin to BCD) - and this addition operation could be vectorized. Commented Oct 25, 2011 at 19:56
  • As for replacing division with multiplication, compile int main(int argc, char **argv) { return argv/10; } with gcc -O2 and look at the assembly it generates. Commented Oct 25, 2011 at 19:57
  • 1
    It's not just multiplying by the reciprocal; that would be floating point math and would be inaccurate because the reciprocal is not exactly representable. The technique is related but somewhat different. Commented Jun 8, 2021 at 2:20