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 <string>
#include <vector>
#include <algorithm>
#include <bitset>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	double n;

	while(cin >> n)
	{
		if(n < 0) break;

		int up = (int)n;
		double down = n - up;

		if(0 <= up && up < 256 && down*16 == (int)(down*16))
		{
			int t = (int)(n*16);
			string s;
			rep(i,12)
			{
				if(i < 4)
				{
					if(t & (1 << i)) s += "1";
					else s += "0";
				}
				else
				{
					if(i == 4) s += ".";

					if(t & (1 << i)) s += "1";
					else s+= "0";
				}
			}

			reverse(s.begin(),s.end());
			cout << s << endl;
		}
		else cout << "NA" << endl;
	}
}

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<ll, 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());
		while (B.size() < 4) B += '0';
		
		ll a = atol(A.c_str()), b = atol(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++: #include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
using namespace std;

unsigned numLen(int n){
	char buf[100];
	return sprintf(buf, "%d", n);
}

int pow(int n, int a){
	int ret = 1;
	for(int i = 0;i < a;i++) ret *= n;
	return ret;
}

void reverse(string &str){
	unsigned len = str.length();
	char t;
	for(unsigned i = 0;i < len / 2;i++){
		t = str[i];
		str[i] = str[len - i - 1];
		str[len - i - 1] = t;
	}
}

string int2bin(int n){
	string ret;
	while(n){
		ret += '0' + (n % 2);
		n /= 2;
	}
	reverse(ret);
	return ret;
}

string double2bin(int r){
	unsigned d = numLen(r);
	string ret;
	for(int i = 0;i < 5;i++){
		r *= 2;
		if(numLen(r) > d){
			ret += '1';
			r -= pow(10, d);
		}
		else{
			ret += '0';
		}
		if(r == 0) break;
	}
	for(int i = ret.length();i < 4;i++) ret += '0';
	return ret;
}

int main(){
	while(1){
		int n, r;
		scanf("%d.%d", &n, &r);
		if(n < 0) break;
		string ansN = int2bin(n), ansR = double2bin(r);
		if(ansN.length() > 8 || ansR.length() > 4) printf("NA\n");
		else{
			cout.width(8);
			cout.fill('0');
			cout << ansN;
			cout << '.';
			cout.width(4);
			cout.fill('0');
			cout << ansR;
			cout << endl;
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <algorithm>
using namespace std;

int main(){
    double x;
    while(scanf("%lf",&x)){
        if(x<0) break;
        x *= 16;
        if(x > (1<<16)-1)
            printf("NA");
        else if(x == (int)x){
            char str[20];
            str[8] = '.';
            str[13] = '\0';
            int n = x;
            for(int i=0; i<12; i++)
                str[(i<4)?(12-i):(11-i)] = (n & (1<<i))?'1':'0';
            printf("%s\n",str);
        }
        else
            printf("NA");
    }

    return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
  double in;
  while(cin>>in,in!=-1){
    double per = in - (int)in;
    if(in>=256){cout<<"NA"<<endl;continue;}
    cout<<(128<=in?1:0);
    if(128<=in)in-=128;
    cout<<(64<=in&&in<128?1:0);
    if(64<=in)in-=64;
    cout<<(32<=in&&in<64?1:0);
    if(32<=in)in-=32;
    cout<<(16<=in&&in<32?1:0);
    if(16<=in)in-=16;
    cout<<(8<=in&&in<16?1:0);
    if(8<=in)in-=8;
    cout<<(4<=in&&in<8?1:0);
    if(4<=in)in-=4;
    cout<<(2<=in&&in<4?1:0);
    if(2<=in)in-=2;
    cout<<(1<=in&&in<2?1:0);
    if(1<=in)in-=1;
    cout<<".";
    cout<<(0.5<=per&&per<1?1:0);
    if(0.5<=per)per-=0.5;
    cout<<(0.25<=per&&per<0.5?1:0);
    if(0.25<=per)per-=0.25;
    cout<<(0.125<=per&&per<0.25?1:0);
    if(0.125<per)per-=0.125;
    cout<<(0.0625<=per&&per<0.125?1:0);
    if(0.0625<per)per-=0.0625;
    cout<<endl;
  }
}

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;
		if (st[0] == '-')break;
		string up = st.substr(0, st.find('.'));
		string down = st.substr(st.find('.') + 1);
		if (st.find('.') == string::npos) {
			up = st;
			down = "0";
		}
		if (down != "0") {
			while (!down.empty() && down.back() == '0') down.pop_back();
		}
		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;
}

C++: #include<iostream>
using namespace std;
int main(){
	double n;
	while(true){
		cin>>n;
		if(n<0.0)break;
		bool na=false;
		if(n>128.0)na=true;
		int x=n/(0.25*0.25);
		if(x*(0.25*0.25)!=n)na=true;
		if(na==true)
			cout<<"NA"<<endl;
		else{
		double a=128;
		while(true){
			int b=n/a;
			cout<<b;
			n-=b*a;
			a/=2;
			if(a==0.5)cout<<'.';
			if(a==0.25*0.25*0.5)
				break;
		}
		cout<<endl;
		}
	}
	return 0;
}