C
Chuck F.
pete said:.... snip ...Jordan said:I'm surprised no one was curious about the fast C-code multiply.
It typically takes shorts in, long out -- a common case.
If you've not seen the trick before, consider it a puzzle
to reverse engineer it from the fragment:
c = arr[x+y] - arr[x-y]; /* c = x * y */
It gives competitive performance even on some machines with
blazingly fast multiplies.
OK, i'll bite - what goes in the array?
int main(void)
{
unsigned x, y, arr[256];
for (x = 0; 255 > x; ++x) {
arr[x] = x * x / 4;
}
And how do you conclude that x*x is divisible by 4? (or even x)?
--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>