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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;


string integer_to_bin(int n, int digits)
{
	string res;
	while (n)
	{
		res += n & 1 ? '1' : '0';
		n >>= 1;
	}
	return string(max(0, digits-(int)res.size()), '0') + res;
}
string fraction_to_bin(double n, int digits)
{
	string res;
	while (n > EPS)
	{
		n *= 2;
		if (n+EPS > 1)
		{
			n -= 1;
			res += '1';
		}
		else
			res += '0';
	}
	return res + string(max(0, digits-(int)res.size()), '0');
}
int main()
{
	double n;
	while (scanf("%lf", &n), n >= 0)
	{
		string integer = integer_to_bin((int)n, 8);
		string fraction = fraction_to_bin(n - (int)n, 4);
		if (integer.size() <= 8 && fraction.size() <= 4)
			printf("%s.%s\n", integer.c_str(), fraction.c_str());
		else
			puts("NA");
	}

	return 0;
}

C++: #include <iostream>

int main(int argc, char* argv[]){
  
  while(true){
    double d;
    
    std::cin >> d;
    
    if(d < 0){
      break;
    }
    
    int i = d;
    int array_i[8] = {0, 0, 0, 0, 0, 0, 0, 0};
    
    if(i > 255){
      std::cout << "NA" << std::endl;
      continue;
    }
    
    for(int k = 0; k < 8; k++){
      array_i[k] = i % 2;
      i /= 2;
    }
    
    double r_d = d - (int)(d);
    int array_d[4] = {0, 0, 0, 0};
    
    {
      double jj = 0.5;
      for(int k = 0; k < 4; k++){
        if(r_d >= jj){
          r_d -= jj;
          array_d[k] = 1;
        }
        jj /= 2;
      }
    }
    
    if(r_d > 0){
      std::cout << "NA" << std::endl;
      continue;
    }
    
    for(int k = 7; k >= 0; k--){
      std::cout << array_i[k];
    }
    std::cout << ".";
    for(int k = 0; k < 4; k++){
      std::cout << array_d[k];
    }
    std::cout << std::endl;
  }
  
}

C++: #include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main()
{
    double n,m;
    int a = 0;
    int res = 0;
    int bai = 1;
    double ans = 0,ahokusa = 0;
    while(cin >> n)
    {
        if(n == -1.0)return 0;
        while(1)
        {
            a = n;
            m = n - a;
            if(a > 256 || m < 0.0625)
            {
                puts("NA");
            }
            else
            {
                while(a > 0)
                {
                    res += (a%2)*bai;
                    a /= 2;
                    bai *= 10;
                }
            }
            ans += res;
            int asukoge = 0;
            for(int i = 1; i < 5; i++)
            {
                if(m == 1/pow(2,i))ahokusa += pow(0.1,i);
                if(i == 16 && ahokusa == 0)
                {
                    puts("NA");
                    break;
                }
            }
            printf("%013.4f\n",ans+ahokusa);
            break;
        }
    }

    return 0;
}

C++: #include<stdio.h>

int main(){
int b1[9]={},b2[9]={};

int x1,x2;

//double x1,x2=0;
//int y1=0,y2=0;
/*
while(scanf("%lf",&x)!=EOF){
x2=x1*10000;
y2=(int)x1;y2*=10000;
y2=(int)x2-(int)x1*10000;
y1=(int)x1;
if(y1>255||y2>9375||b2)

*/

//while(scanf("%d.%d",&x1,&x2)!=EOF){

while(1){
	scanf("%d.%d",&x1,&x2);

	if(x1<=-0)break;
x2*=1000;
if(x1>255||x2>9375||x2<625)printf("NA\n");

else {
if(x1>=128){x1=x1-128;b1[0]=1;}
if(x1>=64){x1=x1-64;b1[1]=1;}
if(x1>=32){x1=x1-32;b1[2]=1;}
if(x1>=16){x1=x1-16;b1[3]=1;}
if(x1>=8){x1=x1-8;b1[4]=1;}
if(x1>=4){x1=x1-4;b1[5]=1;}
if(x1>=2){x1=x1-2;b1[6]=1;}
if(x1>=1){x1=x1-1;b1[7]=1;}

if(x2>=5000){x2=x2-5000;b2[0]=1;}
if(x2>=2500){x2=x2-2500;b2[1]=1;}
if(x2>=1250){x2=x2-1250;b2[2]=1;}
if(x2>=625){x2=x2-625;b2[3]=1;}

if(x1==0&&x2==0)
{
for(int i=0;i<8;i++)
printf("%d",b1[i]);

printf(".");

for(int i=0;i<4;i++)
printf("%d",b2[i]);

printf("\n");

}

else printf("NA\n");


for(int i=0;i<9;i++)
{
b1[i]=0;b2[i]=0;
}


}
}
return 0;
}

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 (down != "0") {

			down = down.substr(0, down.find('0'));
		}
		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;
}