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(void)
{
    int a[9], b[9];
    float m, n, h;
    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++: 	while(cin>>n,n>=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);
	}
	}
}

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

using namespace std;

int main(){
	
	string in;
	string ls,rs;
	string ans;
	int li,ri;
	bool f;
	int sdata[8];
	int fdata[4]={5000,2500,1250,625};

	for(int i=0;i<8;i++){
		sdata[i]=pow(2,i);
	}

	while(1){
		cin>>in;
		if(in=="-1.0") break;

		ls="",rs="";
		f=false;
		for(int i=0;i<in.size();i++){
			if(in[i]=='.') f=true;
			else if(f){
				rs+=in[i];
			}
			else{
				ls+=in[i];
			}
		}

		li=0;
		for(int i=0;i<ls.size();i++){
			li+=(ls[ls.size()-1-i]-'0')*pow(10,i);
		}

		ri=0;
		for(int i=0;i<rs.size();i++){
			ri+=(rs[rs.size()-1-i]-'0')*pow(10,i);
		}
		while(ri<1000) ri*=10;
		ans="";
		for(int i=7;i>=0;i--){
			if(li>=sdata[i]){
				li-=sdata[i];
				ans+="1";
			}
			else ans+="0";
		}
		if(li!=0){
			cout<<"NA"<<endl;
			continue;
		}
		ans+=".";

		for(int i=0;i<4;i++){
			if(ri>=fdata[i]){
				ri-=fdata[i];
				ans+="1";
			}
			else ans+="0";
		}
		if(ri!=0){
			cout<<"NA"<<endl;
			continue;
		}
		cout<<ans<<endl;
	}

}

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;
		for(++index;number[index] != '\0'; index++){
			under = 10*under + (number[index] - '0');
		}

		if(under < 10){
			under *= 1000;
		}else if(under < 100){
			under *= 100;
		}else if(under < 1000){
			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++: /*
 * src.cpp
 *
 *  Created on: 2016/08/04
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const double EPS=1e-10;

#define EQ(a,b) fabs(a-b)<EPS

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

int out[12];

int main(){
	do{
		cin>>r;
		if (r>=0-EPS){
			fill(out,out+12,0);
			REP(i,12){
				if (r>=bin[i]-EPS){
					r-=bin[i];
					out[i]=1;
				}
			}
			if (EQ(r,0)){
				REP(i,8){
					cout<<out[i];
				}
				cout<<'.';
				REP(i,4){
					cout<<out[i+8];
				}
				cout<<endl;
			}else{
				cout<<"NA"<<endl;
			}
		}
	}while (r>=0-EPS);
	return 0;
}

C++: // AOJ 0220
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
	double n;
	while (cin >> n, n >= 0){
		string ret;
		int a = (int)n;
		while (a != 0){
			if (a == 1){
				ret += '1';
				break;
			}
			if (a % 2 == 0){
				a /= 2;
				ret += '0';
			}
			else {
				a /= 2;
				ret += '1';
			}
		}
		// cout << ret.length() << endl;
		for (int i = ret.length(); i < 8; i++) ret += '0';
		// cout << ret.length() << endl;
		reverse(ret.begin(), ret.end());
		ret += '.';

		string ret2;
		map <double, bool> memo;
		bool f = true;
		n -= (int)n;
		while (n != 0){
			if (memo[n]){
				f = false;
				break;
			}
			n *= 2.0;
			if (n >= 1.0){
				ret2 += '1';
				n -= 1.0;
			}
			else {
				ret2 += '0';
			}
			// cout << n << endl;
			memo[n] = true;
		}
		for (int i = ret2.length(); i < 4; i++) ret2 += '0';
		// reverse(ret2.begin(), ret2.end());

		if (!f){
			cout << "NA" << endl;
		}
		else {
			cout << ret << ret2 << endl;
		}
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    vector< pair<double,string> > num;
    double d[] = {0.5,0.25,0.125,0.0675};
    REP(i,2){
	REP(j,2){
	    REP(k,2){
		REP(l,2){
		    num.PB( pair<double,string>(i*d[0] + j*d[1] + k*d[2] + l*d[3],to_string(i)+to_string(j)+to_string(k)+to_string(l)));
		}
	    }
	}
    }


    while(true){
	double n;
	cin >> n;
	if(n<0) break;
	int m = (int)(n);
	n -= (double)(m);
	if((m&(0xff00))==0){
	    bool flg = false;
	    REP(i,num.size()){
		if(n == num[i].first) {
		    flg = true;
		    stack<int> ans;
		    while(m>0){
			ans.push(m%2);
			m /= 2;
		    }
		    REP(i,8-ans.size()){
			cout << 0;
		    }
		    while(!ans.empty()){
			cout << ans.top();
			ans.pop();
		    }
		    cout << "." + num[i].second << endl;
		    break;
		}
	    }
	    if(!flg) cout << "NA" << endl;
	}else{
	    cout <<"NA"<<endl;
	}
    }
    return 0;
}