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 <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        double a;
        cin >> a;
        if(a < 0.0)
            return 0;

        string s;
        double b = (1<<7);
        for(int i=0; i<12; ++i){
            if(i == 8)
                s += '.';
            if(a >= b){
                s += '1';
                a -= b;
            }else{
                s += '0';
            }
            b /= 2.0;
        }

        if(a == 0.0)
            cout << s << endl;
        else
            cout << "NA" << endl;
    }
}

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;
			}
		}

		bool flag = true;

		for(unsigned long int i = 10000000; true; i /= 10)
		{
			if(flag && tmpi == 0)
			{
				flag = false;
				i /= 10; 
			}

			if(tmpi >= i)
			{
				break;
			}

			cout << '0';
		}

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

	}
}

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

int main(){
  int i;
  double n,ans,j;
  while(1){
    cin >> n;
    if(n < 0) break; 
    j = 128;
    ans = 0.0;
    for(i=10000000;i>=1;i/=10){
      if(n - j >= 0.0){
	ans += (double)i;
	n -= j;
      }
      j /= 2.0;
    }
    j = 0.5;
    for(i=10;i<=10000;i*=10){
      if(n - j >= 0.0){
	ans += (double)1/i;
	n -= j;
      }
      j /= 2.0;
    }
    if(n == 0.0) printf("%013.4f\n",ans);
    else cout << "NA" << endl;
  }
  return 0;
}

C++: #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>

using namespace std;

int main(){

	char ans_upper[9],ans_under[5];
	int upper,under,S;
	double number;

	while(true){
		scanf("%lf",&number);
		if(number < 0)break;

		upper = (int)round(number);

		if(upper >= 256){
			printf("NA\n");
			continue;
		}

		S = 128;

		for(int i = 0; i < 8; i++){
			if(upper >= S){
				ans_upper[i] = '1';
				upper -= S;
			}else{
				ans_upper[i] = '0';
			}
			S /= 2;
		}

		ans_upper[8] = '\0';


		under = 10000*(number - 1.0);

		for(int i = 0; i < 4; i++){
			under *= 2;
			if(under/10000 >= 1){
				ans_under[i] = '1';
			}else{
				ans_under[i] = '0';
			}
			under %= 10000;
		}

		if(under != 0){
			printf("NA\n");
			continue;
		}

		ans_under[4] = '\0';

		printf("%s.%s\n",ans_upper,ans_under);

	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((-(b))+((a)))<EPS)

int main(){

	double d;
	while(cin>>d&&!EQ(d,-1)){
		int r = (int)d;
		double im=d-r;
		if(r>=256){
			cout<<"NA"<<endl;
			continue;
		}
		else{
			vector<int> v;
			while(r>0){
				v.push_back(r%2);
				r/=2;
			}
			// ÀÌZ
			bool match=false;
			int s;
			for(int i = 0; i < 16; i++){
				double d=0;
				for(int j = 0; j < 4; j++){
					if((i>>j)&1){
						d+=pow(0.5,j+1);
					}
				}
				if(EQ(d,im)){
					match=true;
					s=i;
					break;
				}
			}
			if(match){
				for(int i = 0; i < 8-v.size(); i++){
					cout<<0;
				}
				for(int i = 0; i < v.size(); i++){
					cout<<v[v.size()-1-i];
				}
				cout<<'.';
				// ¬_Ì\¦
				for(int i = 0; i < 4; i++){
					if((s>>i)&1)
						cout<<1;
					else
						cout<<0;
				}
				cout<<endl;
			}
			else
				cout<<"NA"<<endl;
		}
	}

	return 0;
}

C++: #include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <queue>
#include <string>
#include <map>
#include <vector>

using namespace std;

int main() {
  for (;;) {
    char s[16], r[16];
    r[8] = '.';
    r[13] = '\0';
    fill(s, s+16, 0);
    scanf("%s", s);
    if (s[0] == '-') return 0;
    int a, b, d = 0;
    while (s[d] && s[d] != '.') d++;
    if (!s[d]) {
      sscanf(s, "%d", &a);
      if (a >= 1 << 9) {
        puts("NA");
        continue;
      }
      r[9] = r[10] = r[11] = r[12] = '0';
      goto print_a;
    }
    for (int i = 1; i <= 4; i++)
      if (!s[d+i])
        s[d+i] = '0';
    sscanf(s, "%d.%d", &a, &b);
    if (a >= 1 << 9) {
      puts("NA");
      continue;
    }
    for (int i = 1; i <= 4; i++) {
      int x = 10000 / (1 << i);
      if (b >= x) {
        b -= x;
        r[8+i] = '1';
      } else
        r[8+i] = '0';
    }
    if (b) {
      puts("NA");
      continue;
    }
print_a:
    for (int i = 0; i < 8; i++)
      if ((a >> i) & 1)
        r[7-i] = '1';
      else
        r[7-i] = '0';
    puts(r);
  }
}