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>
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

int main()
{
    string s;
    while(true) {
        cin >> s;
        if(s.size() <= 0 || s[0] == '-')
            break;
        
        int a, b;
        a = 0;
        for(int i = 0; i < s.find('.'); i++) 
            a = a * 10 + s[i] - '0';

        b = 0;
        for(int i = 0; i < 4; i++) {
            if(i + s.find('.') + 1 < s.size()) {
                b = b * 10 + s[i + s.find('.') + 1] - '0';
            } else {
                b *= 10;
            }
        }
        
        string sa, sb;
        int s,m;
        sa = "00000000";
        s = m = a;
        for(int i = 7; i >= 0; i--) {
            m = s % 2;
            s /= 2;
            sa[i] += m;
        }

        sb = "0000";        
        s = b;
        for(int i = 0; i < 4; i++) {
            s *= 2;
            sb[i] += s / 10000;
            s %= 10000;
        }

        if(a > 255 || s != 0) 
            cout << "NA" << endl;
        else 
            cout << sa << "." << sb << endl;
            
    }
}

C++: #include <iostream>

using namespace std;


void solve()
{
	double a[16];
	for(int i = 0; i < 16; ++i)
	{
		a[i] = i / 16.0;
	}
	double n;
	while(cin >> n, n >= 0)
	{
		char c[13];
		bool flag =true;
		for(int i = 0; i < 16; ++i)
		{
			if(n - (int)n == a[i])
			{
				flag = false;
				for(int j = 12; j >= 9; --j)
				{
					c[j] = i % 2 + '0';
					i /= 2;
				}
				break;
			}
		}
		if(flag)
		{
			cout << "NA" << endl;
			goto NEXT;
		}
		c[8] = '.';
		int num = (int)n;
		for(int i = 7; i >= 0; --i)
		{
			c[i] = num % 2 + '0';
			num /= 2;
		}
		for(int i = 0; i < 13; ++i)
		{
			cout << c[i];
		}
		cout << endl;
NEXT:
		;
	}
}

int main()
{
	solve();
	return(0);
}

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

int main()
{
    double n;
    while(cin >> n, n >= 0){
        int a = n;
        double b = n - a;
        if(a > 255){
            cout << "NA" << endl;
            continue;
        }
        
        string ans(bitset<8>(a).to_string());
        ans.push_back('.');
        for(int i = 0; i < 4; ++i){
            b *= 2;
            ans.push_back('0' + (int)b);
            b -= (int)b;
        }
        if(b != 0){
            cout << "NA" << endl;
            continue;
        } else {
            cout << ans << endl;
        }
    }
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

int A = 0, B = 0, K = 0, T = 0, W = 0, N = 0, H = 0;
int n = 0;
double L = 0;
double S = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;

string C;
string sA, strB;
vector<vector<char>> map;
vector<double> num;
vector<string> str;

int sum = 0;


double tempd = 0.0;



void input() {
	while (true) {
		CI tempd;
		if (tempd < 0.0) {
			break;
		}
		num.push_back(tempd);
	}

	return;
}


int main(void) {
	double deci;
	int numd;
	vector<int> int_array;
	vector<int> deci_array;
	input();

	for (int i = 0; i < num.size(); i++) {
		numd = num[i];
		deci = num[i] - (double)numd;
		
		while (true) {
			if (numd == 0) {
				break;
			}
			int_array.push_back(numd % 2);
			numd /= 2;
		}
		if (int_array.size() > 8) {
			CO "NA" E
			int_array.clear();
			int_array.shrink_to_fit();
			deci_array.clear();
			deci_array.shrink_to_fit();
			continue;
		}
		 
		bool flag = false;
		int nx = 0;
		while (true) {
			if (deci == (double)(int)deci) {
				break;
			}
			nx++;
			deci *= 2;
			deci_array.push_back((int)deci % 10);
		
		
			if (deci_array.size() > 4) {
				CO "NA" E
				int_array.clear();
				int_array.shrink_to_fit();
				deci_array.clear();
				deci_array.shrink_to_fit();
				flag = true;
				break;
			}
		}
		if (flag) {
			flag = false;
			continue;
		}
		

		for (int j = 0; j < 8 - int_array.size(); j++) {
			CO 0;
		}
		for (int j = int_array.size() - 1; j >= 0; j--) {
			CO int_array[j];
		}
		CO ".";
		for (int j = 0; j < deci_array.size(); j++) {
			CO deci_array[j];
		}
		for (int j = 0; j < 4 - nx; j++) {
			CO 0;
		}
		CO "\n";
		int_array.clear();
		int_array.shrink_to_fit();
		deci_array.clear();
		deci_array.shrink_to_fit();
	}


	return 0;
}

C++: #define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

static const double eps = 1e-8;

int main(){
	double n;	
	while(~scanf("%lf",&n)){
		if(n==-1.0) break;
		int a = n;
		double b = n - (double)a;

		bitset<8> front;
		for(int i=0;i<8;i++){
			if(a & (1<<i)) front |= (1<<i);
		}

		bitset<4> rear;
		for(int i=0;i<4;i++){
			b*=2.0;
			if(b + eps > 1.0){
				rear |= (1<<i);
				b -= 1.0;
			}
		}

		if(!(b+eps > 0.0 && b-eps < 0.0) || a != front.to_ulong()) {
			printf("NA\n");
		}
		
		
		else {
			string r = rear.to_string();
			reverse(r.begin(),r.end());
			printf("%s.%s\n",front.to_string().c_str(),r.c_str());
		}
	}
}

C++: #include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int n;
  string s,t,u;
  while(cin>>s&&s[0]!='-'){
    n=atoi(s.substr(0,s.find(".")).c_str());
    if(n>255){
      cout<<"NA"<<endl;
      continue;
    }
    t=u="0000";
    for(i=1;i<(int)(s.length()-s.find("."));i++)
      t[i-1]=s[s.find(".")+i];
    if(t[0]>'4'){
      t[0]-=5;
      u[0]++;
    }
    if(t[0]>'1'&&t[1]>'4'){
      t[0]-=2;
      t[1]-=5;
      u[1]++;
    }
    if(t[0]>'0'&&t[1]>'1'&&t[2]>'4'){
      t[0]-=1;
      t[1]-=2;
      t[2]-=5;
      u[2]++;
    }
    if(t[1]>'5'&&t[2]>'1'&&t[3]>'4'){
      t[1]-=6;
      t[2]-=2;
      t[3]-=5;
      u[3]++;
    }
    if(t!="0000"){
      cout<<"NA"<<endl;
      continue;
    }
    for(i=0;i<8;i++){
      cout<<n/(int)pow(2,7-i);
      n%=(int)pow(2,7-i);
    }
    cout<<"."<<u<<endl;
  }
  return 0;
}