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

	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] = {};
		
		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

C++: #include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define elif(a) else if(a)
#define INF INT_MAX
#define F first
#define S second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int a,b;
double g;
ll c,d;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(1){
    scanf("%lf",&g);
    if(g==-1) break;
    if(a>=256){
      printf("NA\n");
      continue;
    }
    a=(int)g;
    g=g-(int)g;
    int cnt=0,p=1;
    c=d=0;

    while(cnt<4){

      g*=2;
      d*=10;
      if((int)g==1){
        d++;
        g-=1;
      }

      cnt++;
    }


    if(g!=1.0 && g!=0.0){
      printf("NA\n");
      continue;
    }

    cnt=0;

    while(a>1){
      if(a%2==1) c+=p;
      cnt++;
      p*=10;
      a/=2;
    }
    if(a==1) c+=p;
    if(cnt>=8){
      printf("NA\n");
    }else{
      printf("%08d.",c);
      printf("%04d\n",d);
    }
  }
  return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
const double eps = 1e-9;

int main() {
    double n;
    while (cin >> n, 0 <= n) {
        if (abs(n*16 - round(n*16)) < eps && n < 256 + eps) {
            for (int i=7; i>=-4; --i) {
                double d = pow(2, i);
                if (d < n + eps) {
                    n -= d;
                    cout << "1";
                } else {
                    cout << "0";
                }
                if (i == 0) cout << ".";
            }
            cout << endl;
        } else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
    double d;
    while (cin >> d, d >= 0.0000000) {
        int n = floor(d);
        if (n >= 1 << 8) {
            cout << "NA" << endl;
            continue;
        }

        string str;
        while (n) {
            str = (n % 2 == 0 ? "0" : "1") + str;
            n /= 2;
        }
        while (str.size() < 8) str = "0" + str;
        str += ".";

        double s = d - (double)floor(d);
        double v[] = {0.5, 0.25, 0.125, 0.625};
        for (int i = 0; i < 4; i++) {
            if (s >= v[i]) {
                s -= v[i];
                str += "1";
            } else {
                str += "0";
            }
        }
        if (s) {
            cout << "NA" << endl;
        } else {
            cout << str << endl;
        }
    }

    return 0;
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  double d;
  while (IN(d), d >= 0) {
    string s = "";

    for (double i = 128; i > 0.06; i /= 2) {

      if (d >= i) {
        s += '1';
        d -= i;
      }
      else s += '0';

      if (i == 1) s += '.';
    }

    OUTL(d ? "NA" : s);
  }

  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int n;
	string sm;
	while(scanf("%d.", &n)){
		cin >> sm;
		while(1){
			if(sm.length() == 4){
				break;
			}
			sm+="0";
		}
		int m = StrToInt(sm);
		if(n < 0)break;
		if(n > 511){
			cout << "NA" << endl;
			continue;
		}
		bitset<8> re(n);

		int d[4] = {0};
		double d_ans = 0.5;
		rep(i, 4){
			d[i] = (int)(d_ans*10000);
			d_ans /= 2.0;
		}
		string s;
		rep(i, 4){
			if(m >= d[i]){
				m -= d[i];
				s+="1";
			}else{
				s+="0";
			}
		}
		if(m != 0){
			cout << "NA" << endl;
			continue;
		}

		cout << re << "." << s << endl;
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}