Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"math"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	two := make([]float64, 12)
	flag := make([]int, 12)
	for i := 0; i < 12; i++ {
		two[i] = math.Pow(2.0, 7.0-float64(i))
	}
	for scanner.Scan() {
		n, _ := strconv.ParseFloat(scanner.Text(), 64)
		if n < 0 {
			break
		}
		for i := 0; i < 12; i++ {
			flag[i] = 0
			if n >= two[i] {
				n -= two[i]
				flag[i] = 1
			}
		}
		if n < 10e-10 {
			i := 0
			for i < 12 {
				fmt.Printf("%d", flag[i])
				if i == 7 {
					fmt.Printf(".")
				}
				i++
			}
			fmt.Printf("\n")
		} else {
			fmt.Println("NA")
		}
	}
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

bool func();

int main()
{
	while(func()){};
	
	return false;
}

bool func()
{
	while(true)
	{
		double n = 0.0;

		cin >> n;

		if(n < 0)
		{
			return false;
		}

		double tmpi = 0;
		double d = 0; // 整数部格納
		double doubl_e = modf(n, &d); // 小数部格納
		int in_t = d;

		for(int i = 0; true; i++)
		{
			if(i > 8)
			{
				cout << "NA" << endl;
				return true;
			}

			tmpi += (in_t % 2) * pow(10, (double)i);
		
			in_t /= 2;


			if(in_t == 0)
			{
				break;
			}
		}

		int spi = 0;

		for(spi = 1; true; spi++)
		{
			if(spi >= 5)
			{
				cout << "NA" << endl;
				return true;
			}

			doubl_e *= 2;

			if(doubl_e >= 1)
			{
				doubl_e -= 1;
				tmpi += 1 * pow(10, (double)-spi);
			}

			if(doubl_e == 0)
			{
				break;
			}
		}
		
		for(int i = 7;true;i--)
		{
			if(tmpi >= pow(10, (double)i))
			{
				break;
			}
			
			cout << '0';
		}

		printf("%.4lf\n",  tmpi);

	}
}

C++: #include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	map<int, string> ma, mb;
	REP(i, 1<<8) {
		string str = "";
		int sum = 0;
		
		REP(j, 8) {
			if (i >> j & 1) sum += 1<<j;
			str += '0' + (i >> j & 1);
		}
		
		reverse(ALL(str));
		ma[sum] = str;
	}
	
	int num[4] = {5000, 2500, 1250, 625};
	REP(i, 1<<4) {
		string str = "";
		int sum = 0;
		
		REP(j, 4) {
			if (i >> j & 1) sum += num[j];
			str += '0' + (i >> j & 1);
		}
		mb[sum] = str;
	}
	
	string str;
	while (cin >> str, str[0] != '-') {
		string A = str.substr(0, str.find('.'));
		string B = str.substr(str.find('.') + 1, str.size());
		
		int z = 0;
		while (z < A.size() && A[z] == '0') z++;
		if (z == A.size()) A = "0";
		else A = A.substr(z, A.size());
		
		z = B.size() - 1;
		while (z >= 0 && B[z] == '0') z--;
		z++;
		if (z == 0) B = "0";
		else B = B.substr(0, z);
		
		if (A.size() > 4 || B.size() > 4) { puts("NA"); continue; }
		
		while (B.size() < 4) B += '0';
		
		int a = atoi(A.c_str()), b = atoi(B.c_str());
		
		if (ma.find(a) == ma.end() || mb.find(b) == mb.end()) puts("NA");
		else cout << ma[a] << "." << mb[b] << endl;
	}
	
	return 0;
}

C++: // AOJ 0220
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main()
{
	double n;
	while (cin >> n, n >= 0){
		string ret;
		int a = (int)n;
		while (a != 0){
			if (a == 1){
				ret += '1';
				break;
			}
			if (a % 2 == 0){
				a /= 2;
				ret += '0';
			}
			else {
				a /= 2;
				ret += '1';
			}
		}
		// cout << ret.length() << endl;
		for (int i = ret.length(); i < 8; i++) ret += '0';
		// cout << ret.length() << endl;
		reverse(ret.begin(), ret.end());
		ret += '.';

		string ret2;
		map <double, bool> memo;
		bool f = true;
		n -= (int)n;
		while (n != 0){
			if (memo[n]){
				f = false;
				break;
			}
			n *= 2.0;
			if (n >= 1.0){
				ret2 += '1';
				n -= 1.0;
			}
			else {
				ret2 += '0';
			}
			// cout << n << endl;
			memo[n] = true;
		}
		for (int i = ret2.length(); i < 4; i++) ret2 += '0';
		// reverse(ret2.begin(), ret2.end());

		if (!f){
			cout << "NA" << endl;
		}
		else {
			cout << ret << ret2 << endl;
		}
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
std::vector<int> dparttobinary(double n){
	std::vector<int> vec;
	while(n != 0){
		n *= 2;
		int ipart = (int)n;
		vec.push_back(ipart);
		n = n - (double)ipart;
	}
	return vec;
}

std::vector<int> iparttobinary(int n){
	std::vector<int> vec;
	while(n != 0){
		vec.push_back(n % 2);
		n /= 2;
	}
	std::reverse(vec.begin(), vec.end());
	return vec;
}

int main(){
	std::cout << std::numeric_limits<int>::max();
	double n;
	while(std::cin >> n, n > 0){
		int ipart = (int)n;
		double dpart = n - (double)ipart;
		std::vector<int> dvec = dparttobinary(dpart),
			ivec = iparttobinary(ipart);
	
		if(dvec.size() <= 4 && ivec.size() <= 8){
			for(int i=8-ivec.size();i;i--)
				std::cout << "0";
			for(int i=0;i<ivec.size();i++)
				std::cout << ivec[i];
			std::cout << ".";
			for(int i=0;i<dvec.size();i++)
				std::cout << dvec[i];
			for(int i=4-dvec.size();i;i--)
				std::cout << "0";
			std::cout << "\n";
		}else{
			std::cout << "NA\n";
		}
	}
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
long long int powint(long long int a, long long int b) {
	assert(b >= 0);
	if (b == 0)return 1;
	if (b == 1)return a;
	long long int ans = 1;
	long long int aa = powint(a, b / 2);
	ans *= aa*aa;
	if (b % 2)ans *= a;
	return ans;
}
//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"



string to_string_keta(const long long int l, const int keta) {
	ostringstream oss;

	oss << std::setw(keta) << std::setfill('0') << l;

	return oss.str();
}
int main() {
	while (1) {
		string st; cin >> st;
		string up = st.substr(0, st.find('.'));
		string down = st.substr(st.find('.') + 1);
		if (stoi(up)< 0)break;
		else {
			int ap = stoi(up);
			if (ap >= powint(2, 8)) {
				cout << "NA" << endl;
				continue;
			}
			else {
				string ans;
				for (int i = 7; i >= 0; --i) {
					if (ap >= powint(2, i)) {
						ans.push_back('1');
						ap -= powint(2, i);
					}
					else {
						ans.push_back('0');
					}
				}
				ans.push_back('.');
				bool ok = false;
				for (int i = 0; i <= 15; ++i) {
					int ast = 625 * i;
					string aast = to_string_keta(ast, 4);
					while (!aast.empty()&&aast.back() == '0') aast.pop_back();
					if (aast.empty())aast = "0";
					if (aast == down) {
						ok = true;
						int num = i;
						for (int j = 3; j >=0; --j) {
							if (num >= powint(2, j)) {
								ans.push_back('1');
								num -= powint(2, j);
							}
							else {
								ans.push_back('0');
							}
						}
					}
				}
				if (!ok) {
					cout << "NA" << endl;
					continue;
				}
				else {
					cout << ans << endl;
				}
			}
		}
	}
	return 0;
}