-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
limit.cpp
46 lines (42 loc) · 802 Bytes
/
limit.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdio.h>
#include <math.h>
#include <stdint.h>
union fi {
float f;
uint32_t i;
};
void put(uint32_t xi)
{
fi fi;
fi.i = xi;
float x = fi.f;
printf("%08x exp(%e:%a)=%e(:%a)\n", xi, x, x, exp(x), exp(x));
}
void putCoeff()
{
float tbl[] = {
1,
1,
0.499992894870871676569001141213,
0.166665402458828552475600344586,
0.0418783362899079300060205008974,
0.00836639210105976534636108550722
};
for (size_t i = 0; i < sizeof(tbl)/sizeof(tbl[0]); i++) {
fi fi;
fi.f = tbl[i];
printf("%.7e 0x%08x,\n", fi.f, fi.i);
}
}
int main()
{
const uint32_t minx = 0xc2aeac50;
const uint32_t maxx = 0x42b17218;
uint32_t tbl[] = {
minx + 1, minx, minx - 1, maxx - 1, maxx, maxx + 1
};
for (size_t i = 0; i < sizeof(tbl)/sizeof(tbl[0]); i++) {
put(tbl[i]);
}
putCoeff();
}