查一下书本的82页图2-36的表就行了
float u2f(unsigned u) {return *(float *) &u;
}float fpwr2(int x) {unsigned exp, frac;unsigned u;// 小于最小的非规格化数if (x < -149) {exp = 0;frac = 0;}// 非规格化数else if (x < -126) {exp = 0;frac = 1 << (x + 149);}// 规格化数else if (x < 128) {exp = x + 127;frac = 0;}// 大于最大规格化数else {exp = 255;frac = 0;}u = exp << 23 | frac;return u2f(u);
}