Skip to content

Instantly share code, notes, and snippets.

@neuro-sys
Last active December 16, 2020 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neuro-sys/87e84080343fe26067ce2c205b100ff2 to your computer and use it in GitHub Desktop.
Save neuro-sys/87e84080343fe26067ce2c205b100ff2 to your computer and use it in GitHub Desktop.
mul table
1 2 3 4 5 6 7 8 9
--- --- --- --- --- --- --- --- ---
1 | 1 2 3 4 5 6 7 8 9
2 | 2 4 6 8 10 12 14 16 18
3 | 3 6 9 12 15 18 21 24 27
4 | 4 8 12 16 20 24 28 32 36
5 | 5 10 15 20 25 30 35 41 45
6 | 6 12 18 24 30 36 42 48 54
7 | 7 14 21 28 35 42 49 56 63
8 | 8 16 24 32 41 48 56 65 72
9 | 9 18 27 36 45 54 63 72 81
#include <stdio.h>
#include <math.h>
#define E 2.718281828459
#define LEN 128
int main(int argc, char *argv[])
{
int i;
unsigned short logTable[LEN]; // 8.8
unsigned short eTable[256]; // 16.0
memset(logTable, 0, sizeof(LEN));
memset(eTable, 0, sizeof(eTable));
for (i = 1; i < LEN; i++) {
logTable[i] = log(i) * 256; // 8.8
}
for (i = 1; i < LEN; i++) {
eTable[logTable[i] >> 3] = i; // pow(E, log(i)); // 16.0
}
int a, b;
printf(" "); for (a = 1; a < 10; a++) printf("%t %3d", a); puts("");
printf(" "); for (a = 1; a < 10; a++) printf("%t ---", a); puts("");
for (a = 1; a < 10; a++) {
printf("%3d | ", a);
for (b = 1; b < 10; b++) {
printf("%t %3d", eTable[(logTable[a] + logTable[b]) >> 3]);
}
puts("");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment