2013
12-04

# Hat’s IEEE

Your program will be given floating point numbers (32-bit), and calculate
exponent and fraction.

IEEE 754:
SEEEEEEEEFFFFFFFFFFFFFFFFFFFFFFF

S = sign(1)
E = exponent(8)
F = fraction(23)

NOTE: If you donnot know IEEE 754,you can baidu it:)

Each line contains a numbers.

For each case, output a line containing two numbers, e (exponent) and f (fraction), by a single space. Fraction must be rounded to six digits after the decimal point.

6560.91
-6560.91

12 1.601785
12 -1.601785

NOTE: INTEL CPU

Problem – 1289

好题。其实就是模拟IEEE754的格式，不过要注意的是，这里用的32位是float，用double就不对了。

#include <cstdio>
#include <cmath>
#include <iostream>

using namespace std;

int main() {
float x;
while (cin >> x) {
int cnt = 0;
while (fabs(x) >= 2.0) x /= 2.0, cnt++;
while (fabs(x) < 1.0) x *= 2.0, cnt--;
printf("%d %.6f\n", cnt, x);
}
return 0;
}

——written by Lyon

1. simple, however efficient. A lot of instances it is difficult to get that a??perfect balancea?? among usability and appearance. I must say that youa??ve done a exceptional task with this. Also, the blog masses quite fast for me on Web explore.

2. 很高兴你会喜欢这个网站。目前还没有一个开发团队，网站是我一个人在维护，都是用的开源系统，也没有太多需要开发的部分，主要是内容整理。非常感谢你的关注。