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<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 (B.size() > 5) ok = false;
		if (A.size() > 5) ok = false;
		
		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 <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<bits/stdc++.h>
using namespace std;
int main(){
  int n,j;
  double qq;
  scanf("%lf",&qq);
  n=(int)qq;
  j=(int)(1000*qq)-1000*n;
  //cout<<n<<' '<<j<<endl;
  while(n>=0){
    int nn=n;
    int ji[8],kyo[4],a=0;
    for(int i=0;i<8;i++){
      if(nn%2!=0){
	ji[i]=1;
      }else{
	ji[i]=0;
      }
      nn=nn/2;
      // cout<<nn<<endl;
    }
    if(nn){
      a=1;
    }else if(j<10000){
      while(j<1000){
	j*=10;
      }
      int c=5000;
      for(int i=0;i<4;i++){
	//cout<<j<<endl;
	if((j-c)>=0){
	  kyo[i]=1;
	  j-=c;
	}else{
	  kyo[i]=0;
	}
	c/=2;
      }
    }
    if(j){
      a=1;
    }
    if(a==0){
      for(int i=7;i>=0;i--){
	cout<<ji[i];
      }
      cout<<'.';
      for(int i=0;i<4;i++){
	cout<<kyo[i];
      }
      cout<<endl;
    }else{
      cout<<"NA"<<endl;
    }
    scanf("%lf",&qq);
    n=(int)qq;
    j=(int)(1000*qq)-1000*n;
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
	while(1){
		int a,m;
		double n,mm;
		int ans[9],sans[5];
		cin >> n;
		if(n<0)break;
		m=n;
		mm=(double)n-m;
		if(m>255)cout << "NA" << endl;
		else{
			int rank=8,nn=128;
			while(rank>0){
				ans[8-rank]=m/nn;
				m=m%nn;
				nn=nn/2;
				rank--;
			}
			rank=0;
			double nk=0.5;
			while(rank<4){
				if(mm>=nk){
					sans[rank]=1;
					mm-=nk;
				}else sans[rank]=0;
				nk=(double)nk/2;
				rank++;
			}
		}
		if(mm>0)cout << "NA" << endl;
		else{
			for(a=0;a<8;a++)printf("%d",ans[a]);
			printf(".");
			for(a=0;a<4;a++)printf("%d",sans[a]);
			printf("\n");
		}
	}
	return 0;
}

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

int main(void){
  double x;

  while(cin>>x, x!=-1){
    int dec = x;
    double flo = x - dec;

    string decStr = "";
    while(dec != 0){
      if(dec % 2 == 0){
        decStr = '0' + decStr;
      }
      else{
        decStr = '1' + decStr;
      }

      dec /= 2;
    }

    string floStr = "";
    int cnt = 0;

    while(cnt < 4 && flo != 0){
      flo *= 2;
      if(flo >= 1){
        floStr += '1';
        flo -= 1;
      }
      else{
        floStr += '0';
      }
      cnt++;
    }

    if(flo != 0 || decStr.length() > 8){
      cout<<"NA\n";
    }
    else{
      while(decStr.length() != 8) decStr = '0' + decStr;
      while(floStr.length() != 4) floStr += '0';
      cout<<decStr<<"."<<floStr<<endl;
    }
  }

  return 0;
}

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()
{

	map<int, string> sa, sb;
	REP(i, 1<<8) {
		int sum = 0;
		string now = "";
		REP(j, 8) {
			if (i >> j & 1) {
				sum += 1<<j;
				now += '1';
			}
			else now += '0';
		}
		reverse(ALL(now));
		sa[sum] = now;
	}
	
	int tmp[4] = {5000, 2500, 1250, 625};
	REP(i, 1<<4) {
		int sum = 0;
		string now = "";
		REP(j, 4) {
			if (i >> j & 1) {
				now += '1';
				sum += tmp[j];
			}
			else now += '0';
		}
		sb[sum] = now;
	}
		
	string str;
	while (cin >> str) {
		
		if (str.find('.') == string::npos) {
			if (str[0] == '-') break;
			puts("NA");
			continue;
		}
		
		string A = str.substr(0, str.find('.'));
		if (atoi(A.c_str()) < 0) break;
		
		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);
		}
		while (B.size() < 4) B += '0';
		
		int a = atoi(A.c_str()), b = atoi(B.c_str());
		if (sa.find(a) == sa.end() || sb.find(b) == sb.end()) puts("NA");
		else cout << sa[a] << "." << sb[b] << endl;
		
	}
	return 0;
}


// 5