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 <cmath>
#include <sstream>
#include <vector>
using namespace std;

#define EPS (1e-8)
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EQ(a,b) (abs(a-b)<EPS)
#define pb push_back

double n;

string i2s(int i) {
  stringstream ss;
  ss<<i;
  return ss.str();
}

void solve() {
  int real; double imag = n;
  real = (int)imag;
  imag -= (double)real;
  string re, im;
  
  // real
  while (1) {
    if (real / 2 == 0) {
      re.insert(0, "1");
      break;
    }
    if (real % 2) {
      re.insert(0, "1");
    } else {
      re.insert(0, "0");
    }
    real /= 2;
  }
  
  if (re.size() > 8) {
    cout<<"NA"<<endl; return;
  }
  
  // imag
  vector<double> ds;
  ds.pb(imag);
  while (1) {
    imag *= 2;
    
    bool flag = false;
    rep(i,ds.size()) if (EQ(imag, ds[i])) flag = true;
    if (flag) break;
    
    ds.pb(imag);
    if (imag >= 1.0) {
      im += "1";
      imag -= 1.0;
    } else {
      im += "0";
    }
  }
  if (im.size() > 4) {
    cout<<"NA"<<endl; return;
  }
  
  while (im.size()!=4) im+="0";
  while (re.size()!=8) re.insert(0,"0");
  cout<<re<<"."<<im<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    if (n < 0) break;
    solve();
  }
  return 0;
}

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

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((-(b))+((a)))<EPS)

int main(){

	double d;
	while(cin>>d&&!EQ(d,-1)){
		int r = (int)d;
		double im=d-r;
		if(r>=256){
			cout<<"NA"<<endl;
			continue;
		}
		else{
			vector<int> v;
			while(r>0){
				v.push_back(r%2);
				r/=2;
			}
			// ÀÌZ
			bool match=false;
			int s;
			for(int i = 0; i < 16; i++){
				double d=0;
				for(int j = 0; j < 4; j++){
					if((i>>j)&1){
						d+=pow(0.5,j+1);
					}
				}
				if(EQ(d,im)){
					match=true;
					s=i;
					break;
				}
			}
			if(match){
				for(int i = 0; i < 8-v.size(); i++){
					cout<<0;
				}
				for(int i = 0; i < v.size(); i++){
					cout<<v[v.size()-1-i];
				}
				cout<<'.';
				// ¬_Ì\¦
				for(int i = 0; i < 4; i++){
					if((s>>i)&1)
						cout<<1;
					else
						cout<<0;
				}
				cout<<endl;
			}
			else
				cout<<"NA"<<endl;
		}
	}

	return 0;
}

C++: #include <iostream>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
const double EPS = 1e-10;
int main(){
	double d;
	while(cin >> d) {
		if(d == -1) break;
		int ret[13] = {};
		for(int i = 7; i >= -4; --i) {
			if(d>=pow(2,i)) {
				d-=pow(2,i);
				ret[7-i] = 1;
			}
			if(d<EPS) break;
		}
		if(d>=EPS) cout << "NA" << endl;
		else {
			rep(i,8) cout << ret[i];
			cout << ".";
			rep2(i,8,12) cout << ret[i];
			cout << endl;
		}
	}
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;

int main()
{
	string str;
	while (cin >> str) {
		if (str[0] == '-') break;
		
		if (str.find('.') == string::npos) {
			puts("NA");
			continue;
		}
		
		string A = str.substr(0, str.find('.'));
		string B = str.substr(str.find('.') + 1, str.size());
		
		bool ok = true;
		int ans[12] = {};
				
		if (A[0] == '0') {
			int z = 0;
			while (z < A.size() && A[z] == '0') z++;
							
			if (z == A.size()) A = "0";
			else A = A.substr(z);
		}
		
		if (*(B.end() - 1) == '0') {
			int z = B.size() - 1;
			while (z >= 0 && B[z] == '0') z--;
			z++;
			
			if (z == 0) B = "0";
			else B = B.substr(0, z);
		}
		
		if (ok) {
			ll a = atol(A.c_str());
			while (B.size() < 5) B += '0';
			ll b = atol(B.c_str());
			
			REP(i, 8) {
				ans[7 - i] = a % 2;
				a /= 2;
			}
			
			if (a > 0) ok = false;
			else {
			
				REP(i, 4) {
					b *= 2;
					ans[8 + i] = b / 100000;
					b %= 100000;
				}
				
				if (b > 0) ok = false;
			}
		}
		
		if (ok) {
			REP(i, 8) putchar('0' + ans[i]);
			putchar('.');
			FOR(i, 8, 12) putchar('0' + ans[i]);
			puts("");
		}
		else puts("NA");
	}
	return 0;
}


// 5

C++: #include <iostream>
#include <cmath>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
const double EPS = 1e-10;
int main(){
	double d;
	while(cin >> d) {
		if(d == -1) break;
		int ret[13] = {};
		for(int i = 7; i >= -4; --i) {
			if(d>=pow(2,i)) {
				d-=pow(2,i);
				ret[7-i] = 1;
			}
			if(d<EPS) break;
		}
		if(d>=EPS) cout << "NA" << endl;
		else {
			rep(i,8) cout << ret[i];
			cout << ".";
			rep2(i,8,12) cout << ret[i];
			cout << endl;
		}
	}
}

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

int main() {
	double d;
	while(cin >> d, d >= 0) {
		int a = 0;
		string b = "";
		a = d;
		d -= a;
		for(int i = 0; i < 4; i++) {
			b += (char)((d * 2) + '0');
			d *= 2;
			if(d >= 1) d -= 1;
		}
		if(d > 1e-9 || a >= (1 << 8))
			cout << "NA" << endl;
		else {
			for(int i = 0; i < 8; i++) {
				cout << !!(a & (1 << (7-i)));
			}
			cout << "." << b;
			cout << endl;
		}
	}
}

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

using namespace std;

bool func();

int main()
{
	while(func()){};
	
	return false;
}

bool func()
{
	while(true)
	{
		double n = 0.0;

		cin >> n;

		if(n < 0)
		{
			return false;
		}

		double tmpi = 0;
		double d = 0; // 整数部格納
		double doubl_e = modf(n, &d); // 小数部格納
		int in_t = d;

		for(int i = 0; true; i++)
		{
			if(i > 8)
			{
				cout << "NA" << endl;
				return true;
			}

			tmpi += (in_t % 2) * pow(10, (double)i);
		
			in_t /= 2;


			if(in_t == 0)
			{
				break;
			}
		}

		int spi = 0;

		for(spi = 1; true; spi++)
		{
			if(spi >= 5)
			{
				cout << "NA" << endl;
				return true;
			}

			doubl_e *= 2;

			if(doubl_e >= 1)
			{
				doubl_e -= 1;
				tmpi += 1 * pow(10, (double)-spi);
			}

			if(doubl_e == 0)
			{
				break;
			}
		}
		
		for(unsigned long int i = 10000000; true; i /= 10)
		{
			if(tmpi >= i)
			{
				break;
			}

			cout << '0';
		}

		printf("%.4lf\n",  tmpi);

	}
}