j_mayer | 76a6625 | 2007-03-07 08:32:30 +0000 | [diff] [blame] | 1 | #define _GNU_SOURCE |
| 2 | #include <stdint.h> |
| 3 | #include <stdio.h> |
| 4 | #include <math.h> |
| 5 | |
| 6 | int main (void) |
| 7 | { |
| 8 | double d; |
| 9 | uint8_t n; |
| 10 | int i; |
ths | 3b46e62 | 2007-09-17 08:09:54 +0000 | [diff] [blame] | 11 | |
j_mayer | 76a6625 | 2007-03-07 08:32:30 +0000 | [diff] [blame] | 12 | printf("static const uint8_t mfrom_ROM_table[602] =\n{\n "); |
| 13 | for (i = 0; i < 602; i++) { |
Dong Xu Wang | 4abf79a | 2011-11-22 18:06:21 +0800 | [diff] [blame] | 14 | /* Extremely decomposed: |
j_mayer | 76a6625 | 2007-03-07 08:32:30 +0000 | [diff] [blame] | 15 | * -T0 / 256 |
| 16 | * T0 = 256 * log10(10 + 1.0) + 0.5 |
| 17 | */ |
| 18 | d = -i; |
| 19 | d /= 256.0; |
| 20 | d = exp10(d); |
| 21 | d += 1.0; |
| 22 | d = log10(d); |
| 23 | d *= 256; |
| 24 | d += 0.5; |
| 25 | n = d; |
| 26 | printf("%3d, ", n); |
| 27 | if ((i & 7) == 7) |
| 28 | printf("\n "); |
| 29 | } |
| 30 | printf("\n};\n"); |
| 31 | |
| 32 | return 0; |
| 33 | } |