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<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<iostream>
#include<stack>
#include<queue>
using namespace std;
int main(){
	double n,j;
	int i,count;
	bool flag = true;
	stack<int> s;
	queue<int> q;
	while(cin >> n){
		if(n < 0) return 0;
		count = 0;
		i = n; j = n-i;
		while(i > 3 && count < 8){
			s.push(i%2);
			i/=2;
			count++;
		}
		if(count > 8)
			flag = false;
		s.push(i%2);
		s.push(i/2);
		count += 2;
		for(int x=count; x<8; x++)
			s.push(0);
		count=0;
		
		while( j != 1.0  && count < 4){
			q.push(j*2);
			j *= 2;
			if(j > 1)
				j -= 1;
			count++;
		}
		if(count > 4)
			flag=false;
		for(int x=count; x<4; x++)
			q.push(0);

		if(flag == true){
			int size=s.size(), size1=q.size();
			for(int x=0; x<size; x++){
				cout << s.top();
				s.pop();
			}
			cout << ".";
			for(int x=0; x<size1; x++){
				cout << q.front();
				q.pop();
			}
		}
		else{
			cout << "NA";
		}
		
		cout << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<math.h>
using namespace std;


int main(){
  double n;
  double two[12];
  int flag[12];

  for(int i=0;i<12;i++)two[i] = pow(2,7-i);

  while(1){
    cin >> n;
    if(n<0)break;

    for(int i=0;i<12;i++){
      flag[i] = 0;
      if(n >= two[i]){
	n -= two[i];
	flag[i] = 1;
      }
    }
    
    if(n < 10e-10){
      int i = 0; 
      while(i<12){
	cout << flag[i];
	if(i==7)cout << '.';
	i++;
      }
      cout << endl;
    }else cout << "NA" << endl;

  }
}

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

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

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const double EPS = 1.0 / 100000;

long long n,t;

double d[4] = {0.5, 0.25, 0.125, 0.0625};
double u[8] = {128, 64, 32, 16, 8, 4, 2, 1};

int main()
{
    double num;
    while(cin >> num)
    {
        if(num < 0) break;
        
        string ans;

        if(num - 255 > 0) {cout << "NA" << endl; continue;}
        
        REP(8)
        {
            if(num - u[i]> -EPS){num -= u[i]; ans += "1";}
            else ans += "0";
            
        }
        ans += ".";

        REP(4)
        {
            if(num - d[i] > -EPS) {num -= d[i]; ans += "1";}
            else ans += "0";
        }
        //cout << ans << " rest " << num << endl;

        if(num > EPS) {cout << "NA" << endl; continue;} 
        cout << ans << endl;
    }
    return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int a[9], b[9];
	float m, n, h;
	unsigned int i, i2, k;
	scanf("%f", &n);
	while (1) {
		if (n == -1.0) {//-1?????\???????????????
			break;
		}
		for (i = 0; i != 8; i++) {//0?????\?????¨???
			a[i] = 0;
			b[i] = 0;
		}
		k = (int)n;//n?????´??°????????????
		h = n - k;//n????°???°??¨??????h???????????????
		for (i = 0; k >= 1; i++) {
			a[i] = k % 2;//?°???°??\????????°???a[i]?????\???????????????
			k = k / 2;//2??§?????£?????°???k?????\???????????????
		}
		m = 0.5;
		for (i = 0; i != 4; i++) {
			h = h - m;
			if (h == 0.0) {
				b[i] = 1;
				break;
			}
			else if (h > 0.25) {
				b[i] = 1;
			}
			else {
				b[i] = 0;
				h = h + m;
			}
			m = m*0.5;
			for (i2 = 0; i2 < i; i2++) {
				m = m*0.5;
			}
		}
		if (h == 0.0) {
			for (i = 0; i != 8; i++) {
				printf("%d", a[7 - i]);
			}
			printf(".");
			for (i = 0; i != 4; i++) {
				printf("%d", b[i]);
			}
			printf("\n");
		}
		else {
			printf("NA\n");
		}
		scanf("%f", &n);
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;


int main(void){
	double n;
	while(cin >> n){
		if(n<0.0) break;
		double f=16*n;
		int i=f;

		bool ok=true;
		if(f!=i) ok=false;
		if(i>=4096) ok=false;
		if(ok){
			for(int j=11;j>=4;--j){
				cout << ((i&(1<<j))>0);
			}
			putchar('.');
			for(int j=3;j>=0;--j){
				cout << ((i&(1<<j))>0);
			}
			puts("");
		}else{
			puts("NG");
		}
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
int main(){
	double n;

		//for(int i=0;i<ans.size();i++)cout<<ans[i]<<" ";cout<<endl;
	while(cin>>n,n!=-1.0){
	vector<bool>ans(0);
	queue< vector<bool> >bfs;
	bfs.push(ans);
	while(!bfs.empty()){
		vector<bool>tmp=bfs.front();
		bfs.pop();
		if(tmp.size()>12){
		cout<<"NA"<<endl;
		break;
		}
		double sum=0;
		for(int i=0;i<min(8,(int)tmp.size());i++)if(tmp[i])sum+=pow(2,7-i);
		for(int i=0;i<min(4,(int)tmp.size()-5);i++)if(tmp[8+i])sum+=pow(2,-1*(i+1));
		if(sum==n){
		int cnt=0;
		for(int i=0;i<tmp.size();i++){
		cout<<tmp[i];
		if(cnt==7)cout<<'.';
		cnt++;
		}
		for(int i=0;i<12-tmp.size();i++){
		cout<<'0';
		if(cnt==7)cout<<'.';
		cnt++;
		}
		cout<<endl;
		break;
		}
		tmp.push_back(0);
		bfs.push(tmp);
		tmp.erase(tmp.begin()+(tmp.size()-1));
		tmp.push_back(1);
		bfs.push(tmp);
	}
	}
}