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

vector<int>bit;
vector<int>bit2;
void convert(int);

int main(){
  while(1){
    double n, num2;
    int num;
    cin >> n;
    if(n<0) break;
    bit.clear();
    num=(int)n;
    num2=n-num;
    convert(num);

    if(num2==0.5){
      bit2.push_back(1);
      for(int i=0;i<3;i++) bit2.push_back(0);
    }
    else if(num2==0.25){
      bit2.push_back(0);
      bit2.push_back(1);
      bit2.push_back(0);
      bit2.push_back(0);
    }
    else if(num2==0.125){
      bit2.push_back(0);
      bit2.push_back(0);
      bit2.push_back(1);
      bit2.push_back(0);
    }
    else if(num2==0.0625){
      bit2.push_back(0);
      bit2.push_back(0);
      bit2.push_back(0);
      bit2.push_back(1);
    }
    else if(num2==0.1875){
      bit2.push_back(0);
      bit2.push_back(0);
      bit2.push_back(1);
      bit2.push_back(1);
    }
    else if(num2==0.3125){
      bit2.push_back(0);
      bit2.push_back(1);
      bit2.push_back(0);
      bit2.push_back(1);
    }
    else if(num2==0.375){
      bit2.push_back(0);
      bit2.push_back(1);
      bit2.push_back(1);
      bit2.push_back(0);
    }
    else if(num2==0.4375){
      bit2.push_back(0);
      bit2.push_back(1);
      bit2.push_back(1);
      bit2.push_back(1);
    }
    else if(num2==0.5625){
      bit2.push_back(1);
      bit2.push_back(0);
      bit2.push_back(0);
      bit2.push_back(1);
    }
    else if(num2==0.625){
      bit2.push_back(1);
      bit2.push_back(0);
      bit2.push_back(1);
      bit2.push_back(0);
    }
    else if(num2==0.6875){
      bit2.push_back(1);
      bit2.push_back(0);
      bit2.push_back(1);
      bit2.push_back(1);
    }
    else if(num2==0.75){
      bit2.push_back(1);
      bit2.push_back(1);
      bit2.push_back(0);
      bit2.push_back(0);
    }
    else if(num2==0.8125){
      bit2.push_back(1);
      bit2.push_back(1);
      bit2.push_back(0);
      bit2.push_back(1);
    }
    else if(num2==0.875){
      bit2.push_back(1);
      bit2.push_back(1);
      bit2.push_back(1);
      bit2.push_back(0);
    }
    else if(num2==0.9375){
      bit2.push_back(1);
      bit2.push_back(1);
      bit2.push_back(1);
      bit2.push_back(1);
    }
    else{
      cout << "NA" << endl;
      continue;
    }
    int l=bit.size();
    bit2.push_back(-1);
    if(l>8){
      cout << "NA" << endl;
      continue;
    }
    for(int i=0;i<8-l;i++){
      cout << '0';
    }
    for(int i=0;i<l;i++){
      if(bit[i]==-1) break;
      cout << bit[i];
    }
    cout << '.';
    for(int i=0;;i++){
      if(bit2[i]==-1) break;
      cout << bit2[i];
    }
    cout << endl;
  }
  return 0;
}

void convert(int x){
  if(x==0) return;
  convert(x/2);
  bit.push_back(x%2);
}

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

using namespace std;

int main(){

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

	while(true){
		scanf("%s",number);
		if(number[0] == '-')break;

		upper = 0;

		for(index = 0; number[index] != '.';index++){
			upper = 10*upper + (number[index] - '0');
		}

		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 = 0;
		//??????4???????????????????????????
		index++;
		for(int i = 0,p = 0; i < 4; i++){
			if(number[index+p] != '\0'){
				under = 10*under + number[index+p] - '0';
				p++;
			}else{
				under *= 10;
			}
		}

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

void solve(double x) {
	unsigned char y = (char)x;
	if (y != ((int)x)) {
		cout << "NA" << endl;
		return;
	}
	x -= y;
	int res[4] = {0, 0, 0, 0};
	for (int i = 0; i < 4; i++) {
		x *= 2.;
		res[i] = (int)x;
		x -= res[i];
	}
	if (x > 0) cout << "NA" << endl;
	else {
		for (int i = 7; i >= 0; i--) {
			cout << ((y & (1u << i)) >> i);
		}
		cout << '.';
		for (int i = 0; i < 4; i++) {
			cout << res[i];
		}
		cout << endl;
	}
}

int main () {
	double x;
	while (cin >> x, x >= 0.) {
		solve(x);
	}
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	double n;
	while(cin>>n,n>=0){
		int s[20];
		double a;
		int i;
		for(a=128,i=0;i<12;a/=2,i++){
			if(n>=a){
				n-=a;
				s[i]=1;
			}else{
				s[i]=0;
			}
		}
		if(n>1e-9){
			cout<<"NA"<<endl;
		}else{
			for(i=0;i<8;i++){
				cout<<s[i];
			}
			cout<<".";
			for(i=8;i<12;i++){
				cout<<s[i];
			}
			cout<<endl;
		}
	}
	return 0;
}

C++: #include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long UInt64;
typedef long long Int64;

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

typedef pair<int ,int > P;

string sei(int n)
{
	string res="";
	rep(i,8)
	{
		if(n%2==0)
		{
			res+="0";
		}
		else
		{
			res+="1";
		}
		n/=2;
	}

	reverse(all(res));
	return res;
}

string syo(double d)
{
	string res="";
	rep(i,4)
	{
		d*=2;
		if((int)d==1)
		{
			res+="1";
			d-=1.0;
		}
		else
		{
			res+="0";
		}

	}
	if(d!=0.0) return "-1";

	return res;
}

int main()
{
	double d;
	while(cin>>d)
	{
		if(d==-1.0) return 0;
		
		string ans = sei((int)d)+"."+syo(d - (int)d );
		if(ans.size()==13) cout<<ans<<endl;
		else cout<<"NA"<<endl;
		//cout<<ans<<endl;

	}
		return 0;
}

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

using namespace std;

int main(){
    double n;
    while(cin >> n, n >= 0){
	n *= 1 << 4;
	if(n != (int)n || n >= (1 << 13)){
	    cout << "NA" << endl;
	    continue;
	}
	int l = (int)n >> 4, r = n - (l << 4);
	for(int i = 7;i >= 0;i--){
	    cout << ((l >> i) & 1);
	}
	cout << '.';
	for(int i = 3;i >= 0;i--){
	    cout << ((r >> i) & 1);
	}
	cout << endl;
    }
}