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 <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef pair<int, pii> pip;
 
 
 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
 
vector<string> split(const string &s, char c = ' '){
	vector<string> ret;
	stringstream ss(s);
	string t;
	while(getline(ss,t,c)){
		ret.pb(t);
	}
	return ret;
}


int main(){
	string str;
	vector<string> v;
	bool f;
	while(cin>>str){
		if(str[0] == '-') break;
		f = true;
		v = split(str, '.');
		string s, t;
		int a = atoi(v[0].c_str());
		//cout<<v[1]<<endl;
		int b = v.size()>1?atoi(v[1].c_str()):0;
		//cout<<"OK"<<endl;
		//cout<<a<<" "<<b<<endl;
		if(b % 5 != 0) {
			cout<<"NA"<<endl;
			continue;
		}
		double e = atof(str.c_str()) - a;
		while(a > 0){
			s += (char)('0' + a % 2);
			a /= 2;
			if(s.size() > 8) {
				f = false;
				break;
			}
		}
		while(s.size() < 8) s += '0';
		reverse(all(s));
		double d = (double)1/2;
		while(e > 0.0){
			if(e >= d){
				t += '1';
				e -= d;
			} 
			else{
				t += '0';
			}
			d *= (double)1/2;
			if(t.size() > 4){
				f = false;
				break;
			}
		}
		while(t.size() < 4) t += '0';

		cout<<(f?(s+"."+t):"NA")<<endl;
	}
}

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

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;




const int INF = 1000000;
const int mod = 1e9 + 7;


string tobi(int n, int d){
	string ret(d, '0');
	int i = 0;
	while(n > 0){
		ret[i] += n % 2;
		n /= 2;
		i++;
		if(i >= d) return "f";
	}
	reverse(all(ret));
	return ret;
}

string tobi2(double n){
	string ret(4, '0');
	for(int i = 0; i < 4; i++){
		n *= 2;
		ret[i] += (int)n % 2;
		n -= ret[i] - '0';
	}
	return ret;
}

int main(){
	string s;
	while(cin>>s){
		if(s[0] == '-') break;
		string t, u = "0";
		if(s.find(".") == string::npos) t = s, u = "0";
		else {
			t = s.substr(0, s.find("."));
			u += s.substr(s.find("."));
		}

				
		t = tobi(atoi(t.c_str()), 8);
		u = tobi2(atof(u.c_str()));


		if(t == "f" || u == "f") {
			cout<<"NA"<<endl;
			continue;
		}

		cout<<t<<"."<<u<<endl;
	}

}

C++: #include<stdio.h>
int main(void)
{
	int i,a[]={2048,1024,512,256,128,64,32,16,8,4,2,1},x[12],m;
	double n,s;
	while(1){
		scanf("%lf",&n);
		if(n<0)break;
		m=n*16;
		n=n*16;
//		printf("%f\n",n);
		if(n-m>0||n>4095){
			printf("NA\n");
		}
		else{
			for(i=0;i<12;i++){
//			printf("%d %d\n",m-a[i],i);
				if(m-a[i]>=0){
					x[i]=1;
					m-=a[i];
				}
				else{
					x[i]=0;
				}
//				printf("%d\n",m);
			}
			for(i=0;i<12;i++){
				if(i==8){
					printf(".");
				}
				printf("%d",x[i]);
			}
			printf("\n");
		}
	}
	return 0;
}

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[5] = '\0';

		printf("%s.%s\n",ans_upper,ans_under);

	}

	return 0;
}

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] != '.' && i < str.size()) {
			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 <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;




const int INF = 1000000;
const int mod = 1e9 + 7;


string tobi(int n, int d){
	string ret(d, '0');
	int i = 0;
	while(n > 0){
		ret[i] += n % 2;
		n /= 2;
		i++;
		if(i >= d) return "f";
	}
	reverse(all(ret));
	return ret;
}

string tobi2(int n){
	string ret(4, '0');
	int a = 625;
	for(int i = 0; i < 4; i++){
		ret[i] += n / a;
		n %= a;
		a /= 5;
	}
	if(n != 0) return "f";
	reverse(all(ret));
	return ret;
}

int main(){
	string s;
	while(cin>>s){
		if(s[0] == '-') break;
		string t, u;
		if(s.find(".") == string::npos) t = s, u = "0";
		else {
			t = s.substr(0, s.find("."));
			u = s.substr(s.find(".") + 1);
		}
				
		t = tobi(atoi(t.c_str()), 8);
		u = tobi2(atoi(u.c_str()));


		if(t == "f" || u == "f") {
			cout<<"NA"<<endl;
			continue;
		}

		cout<<t<<"."<<u<<endl;
	}

}