#include <iostream>
#include <stdlib.h>
#include <assert.h>
using namespace std;
int main(int argc, char **argv) {
char s[32];
auto finish = argc > 1 ? strtod(argv[1], NULL) : 2.0;
assert(finish != 0.0);
auto format = argc > 2 ? argv[2] : "%.17g";
auto d = finish / 2.0;
auto f = d;
cout << hexfloat;
for (auto i = 0; i < 54; i++) {
snprintf(s, 31, format, d);
assert(strtod(s, NULL) == d);
cout << s << " = " << d << endl;
if (d == finish) break;
f /= 2; d += f;
}
exit(0);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RkbGliLmg+CiNpbmNsdWRlIDxhc3NlcnQuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IG1haW4oaW50IGFyZ2MsIGNoYXIgKiphcmd2KSB7CiAgICBjaGFyIHNbMzJdOwogICAgYXV0byBmaW5pc2ggPSBhcmdjID4gMSA/IHN0cnRvZChhcmd2WzFdLCBOVUxMKSA6IDIuMDsKICAgIGFzc2VydChmaW5pc2ggIT0gMC4wKTsKICAgIGF1dG8gZm9ybWF0ID0gYXJnYyA+IDIgPyBhcmd2WzJdIDogIiUuMTdnIjsKICAgIGF1dG8gZCA9IGZpbmlzaCAvIDIuMDsKICAgIGF1dG8gZiA9IGQ7CiAgICBjb3V0IDw8IGhleGZsb2F0OwogICAgZm9yIChhdXRvIGkgPSAwOyBpIDwgNTQ7IGkrKykgewogICAgICAgIHNucHJpbnRmKHMsIDMxLCBmb3JtYXQsIGQpOwogICAgICAgIGFzc2VydChzdHJ0b2QocywgTlVMTCkgPT0gZCk7CiAgICAgICAgY291dCA8PCBzIDw8ICIgPSAiIDw8IGQgPDwgZW5kbDsKICAgICAgICBpZiAoZCA9PSBmaW5pc2gpIGJyZWFrOwogICAgICAgIGYgLz0gMjsgZCArPSBmOwogICAgfQogICAgZXhpdCgwKTsKfQoK