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 <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll; 
typedef pair<ll, ll> P;
typedef pair<string, ll> PS;

double a;
double table[12] = { 128, 64, 32, 16, 8, 4, 2, 1, 0.5, 0.25, 0.125, 0.0625 };
double f[20];
int k = 0, l = 0;

void dfs(double* a, int i){
	if (i == 12)return;

	if (*a >= table[i]){
		*a -= table[i];
		f[i] = 1;
	}

	dfs(a, i + 1);
}

int main(){
	while (cin >> a){
		if (a < 0) break;
		dfs(&a, 0);
		if (a == 0){
			REP(i, 8){
				cout << f[i];
			}
			cout << '.';
			FOR(i, 8, 12){
				cout << f[i];
			}
			cout << endl;
		}
		else{
			cout << "NA\n";
		}
		REP(i, 12){
			f[i] = 0;
		}
	}
}

C++: #include <iostream>

using namespace std;

int main() {
	double r;
	while (cin >> r, r >= 0) {
		bool is_find = false;
		int n = r; r -= n;
		string ans;
		for (int i = 0; i < 8; ++i) {
			ans = (char)((n & 1) + '0') + ans;
			n >>= 1;
		}

		double nums[4][2] = {
			{0, 1/2.0},
			{0, 1/4.0},
			{0, 1/8.0},
			{0, 1/16.0}
		};

		for (int a = 0; a <= 1; ++a)
			for (int b = 0; b <= 1; ++b)
				for (int c = 0; c <= 1; ++c)
					for (int d = 0; d <= 1; ++d)
						if (nums[0][a] + nums[1][b] + nums[2][c] + nums[3][d] == r) {
							is_find = true;
							ans += ".";
							ans += a + '0';
							ans += b + '0';
							ans += c + '0';
							ans += d + '0';
						}

		if (is_find) cout << ans << endl;
		else cout << "NA" << endl;
	}
}

C++: #include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;

void func(int a, int n)
{
	int num[8];
	rep(i, n){
		num[i] = a%2;
		a /= 2;
	}
	rep(i, n)
		printf("%d", num[n-1-i]);
}

int main()
{
	int a;
	char str[128];
	while(scanf("%d.%s", &a, str), a>=0){
		int b;
		sscanf(str, "%d", &b);
		rep(i, 4-strlen(str))
			b *= 10;
		if(a>=256 || b%625!=0)
			puts("NA");
		else{
			func(a, 8);
			putchar('.');
			func(b/625, 4);
			puts("");
		}
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

string to(int n,int digit){
	string ans;
	while( max(0,digit--) || n)
		ans += n%2 + '0', n /= 2;
	reverse(ans.begin(),ans.end());
	return ans;
}
int main(){
	double num;
	while(cin >> num , num >= 0){
		double a = (int)num , b = (num - a)*16;
		if( a < 256 && b < 16 && b == (int)b){
			cout << to(a,8) << "." << to(b,4) << 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.9)
			{
				flag = false;
				i /= 10; 
			}

			if(tmpi >= i)
			{
				break;
			}

			cout << '0';
		}

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

	}
}

C++: #include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define INF 1e+9
using namespace std;

int main() {
	double n, over = 127, under[4] = {0.5, 0.25, 0.125, 0.0625};
	rep(i, 4) over += under[i];
	while(cin >> n, n != -1.0) {
		double sum = 0;
		vector<char> ans;
		if(n > over) cout << "NA" << endl;
		else {
			for(int i = 7; i > -1; --i) {
				if(sum + (1 << i) <= n) {
					sum += (1 << i);
					ans.push_back('1');
				}
				else ans.push_back('0');
			}
			ans.push_back('.');
			rep(i, 4) {
				if(sum + under[i] <= n) {
					sum += under[i];
					ans.push_back('1');
				}
				ans.push_back('0');
			}
			if(sum == n) rep(i, ans.size() - 1) cout << ans[i];
			else cout << "NA";
			cout << endl;
		}
	}
}

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

int main() {
	char c;
	while(1) {
		string str;
		long long a, b;
		getline(cin, str);
		if(str[0] == '-') {
			break;
		}
		a = b = 0;
		int i = 0;
		while(str[i] != '.') {
			a *= 10;
			a += str[i] - '0';
			i++;
		} i++;
		int d = 1000;
		while(i < str.size()) {
			b += d * (str[i] - '0');
			d /= 10;
			i++;
		}

		a *= 16; b *= 16;
		a += b / 10000;

		if((~(0xfff) & a) || (b % 10000))
			cout << "NA" << endl;
		else {
			for(int i = 0; i < 12; i++) {
				if(i == 8) cout << ".";
				cout << !!(a & (0x1 << (11-i)));
			}cout << endl;
		}
	}
}

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

using namespace std;

int main(){
  double n;

  while(cin >> n , n >= 0){
    string ans = "",tmp = "";
    int integer = n;

    n -= integer;

    while(integer){
      tmp += (integer % 2) + '0';
      integer /= 2;
    }

    int len = (int)tmp.size();
    for(int i = len ; i < 8 ; i++){
      tmp += "0";
    } 

    reverse(tmp.begin(),tmp.end());
    ans += tmp + ".";

    tmp = "";

    for(int i = 0 ; i < 4 ; i++){
      double b = pow(2.0,-(i+1));

      if(n == b){  
	tmp += "1";
	n -= b;
	break;
      }

      if((int)(n / b) == 0){
	tmp += "0";
      }
      else{
	tmp += "1";
	n -= b;
      }
    }

    len = (int)tmp.size();
    for(int i = len ; i < 4 ; i++){
      tmp += "0";
    }  

    if(!n) cout << ans + tmp << endl;
    else cout << "NA" << endl;
  }

  return 0;
}