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

vector<int>bit;

void convert(int);

int main(){
  while(1){
    double n, num2;
    int num;
    cin >> n;
    if(n<0) break;
    bit.clear();
    num=(int)n;
    num2=n-num;
    convert(num);

    string out;
    
    if(num2==0.5){
      out ="1000";
    }
    else if(num2==0.25){
      out="0100";
    }
    else if(num2==0.125){
      out = "0010";
    }
    else if(num2==0.0625){
      out = "0001";
    }
    else if(num2==0.1875){
      out = "0011";
    }
    else if(num2==0.3125){
      out = "0101";
    }
    else if(num2==0.375){
      out = "0110";
    }
    else if(num2==0.4375){
      out = "0111";
    }
    else if(num2==0.5625){
      out = "1001";
    }
    else if(num2==0.625){
      out = "1010";
    }
    else if(num2==0.6875){
      out = "1011";
    }
    else if(num2==0.75){
      out = "1100";
    }
    else if(num2==0.8125){
      out = "1101";
    }
    else if(num2==0.875){
      out = "1110";
    }
    else if(num2==0.9375){
      out = "1111";
    }
    else{
      cout << "NA" << endl;
      continue;
    }

    int l=bit.size();
    if(l>8){
      cout << "NA" << endl;
      continue;
    }
    for(int i=0;i<8-l;i++){
      cout << '0';
    }
    for(int i=0;i<l;i++){
      if(bit[i]==-1) break;
      cout << bit[i];
    }
    cout << '.';
    cout << out;
    cout << endl;
  }
  return 0;
}

void convert(int x){
  if(x==0) return;
  convert(x/2);
  bit.push_back(x%2);
}

C++: #include<iostream>
#include<map>
#include<sstream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

string compute(int n,bool &flag){
  string ret ="";
  while(n>0){
    if (n%2 == 1)ret+="1";
    else ret+="0";
    n/=2;
  }
  if (ret.size() > 8){
    flag=false;
    return "";
  }
  flag=true;
  while(ret.size() != 8)ret+="0";
  reverse(ret.begin(),ret.end());
  return ret;
}

void makeall(map<string,string> &M){
  const int aho[4]={5000,2500,1250,625};
  rep(i,(1<<4)){
    int val=0;
    rep(j,4){
      if ( (i&(1<<j)) != 0)val+=aho[j];
    }
    stringstream sin;
    sin<<val;
    string key;
    sin>>key;
    while(key.size() != 4)key="0"+key;
    string ret="";
    rep(j,4){
      if ( (i&(1<<j)) != 0)ret+="1";
      else ret+="0";
    }
    //    cout << key <<" " << ret << endl;
    M[key]=ret;
 }
}
/*
string compute2(int m,bool &flag){
  const int aho[4]={5000,2500,1250,625};
  rep(i,(1<<4)){
    //cout << i << endl;
    int val=0;
    rep(j,4){
      if ( (i&(1<<j)) != 0)val+=aho[j];
    }
    cout << val << endl;
    if (val == m){
      string ret="";
      rep(j,4){
	if ( (i&(1<<j)) != 0)ret+="1";
	else ret+="0";
      }
      flag=true;
      return ret;
    }
  }
  flag=false;
  return "";
}
*/

main(){
  int n,m;
  char dummy;
  string in;
  map<string,string> M;
  makeall(M);
  while(getline(cin,in)){
    if (in.size() == 0)continue;
  bool isper=false;
    int m=0;
    int cnt=0;
    string ahoge="";
    rep(i,in.size()){
      if (in[i] == '.'){
	isper=true;
	in[i]=' ';
      }else if (isper){
	ahoge+=in[i];
      }
    }
    while(ahoge.size() != 4)ahoge+="0";
    
    stringstream sin(in);
    sin>>n;
    if (n < 0)break;


    
    bool flag;
    string a=compute(n,flag);
    if (!flag){
      cout << "NA" << endl;
      continue;
    }
    //    cout << ahoge << endl;
    if (M.find(ahoge) != M.end())cout << a << "." << M[ahoge] << endl;
    else cout << "NA" << endl;
  }
}

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

using namespace std;

// container utility
#define ALL(x) (x).begin(), (x).end()

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

string func(int x) {
  string ret;
  while(x > 0) {
    ret += char(x % 2 + '0');
    x /= 2;
  }
  
  reverse(ALL(ret));
  return ret;
}

int main() {

  double in;
  
  while(cin >> in && in > 0.0) {
    string int_part = func(int(in));
    in *= 16;// in <<= 4; (integer type only)
    if(ceil(in) != in) {
      cout << "NA" << endl;
    }
    else {
      rep(i, 8-int_part.size()) cout << 0;
      cout << int_part << '.';
      string decimal_part = func(int(in));
      cout << decimal_part.substr(decimal_part.size()-4) << endl;
    }
  }
  
  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

double cut(double x)
{	return x - floor(x);	}
int main()
{
	double n;
	while(cin >> n && 0 <= n)
	{
		vector<char> na, de;

		for(int i = n; i; i /= 2)
			na.push_back(i % 2 + '0');

		int lim = 0;
		for(double i = n; lim < 8; i = cut(i) * 2, lim++)
			if(lim)
			{
				de.push_back((1 <= i) + '0');
				if(floor(i) == i) break;
			}

		if(8 < na.size() || 4 < de.size())
			cout << "NA" << endl;
		else
		{
			while(na.size() < 8)
				na.push_back('0');

			reverse(ALL(na));
			reverse(ALL(de));

			while(de.size() < 4)
				de.push_back('0');

			rep(i, 8)
				cout << na[i] << (i == 7 ? "." : "");
			rep(i, 4)
				cout << de[i] << (i == 3 ? "\n" : "");
		}
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
	double num;
	while(cin>>num,num>0){
	    string str;
		for(double i=128,a;i>0.03125;i/=2){
			str+=int(a=num/i)+'0';
			if(a>=1)num-=i;
			if(i==1)str+='.';
		}
		if(num/0.03125>0)cout<<"NA"<<endl;
		else cout<<str<<endl;
	}
}

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

string int_to_bin(int n) {
  string ret;
  for (int i = 7; i >= 0; i--) {
    ret += (n >> i & 1 ? "1" : "0");
  }
  return ret;
}

string fp_to_bin(string n) {
  n = "0." + n;
  string ret;
  double t = stod(n);
  while (ret.size() <= 32) {
    t *= 2;
    if (t >= 1) {
      ret += "1";
      t -= 1;
    } else {
      ret += "0";
    }
  }
  reverse(ret.begin(), ret.end());
  auto p = ret.find_first_not_of('0');
  if (p != string::npos) ret = ret.substr(p);
  else ret = "0000";
  reverse(ret.begin(), ret.end());
  return ret;
}

int main() {
  string s;
  while (cin >> s, s[0] != '-') {
    stringstream ss(s);
    int a;
    string b;
    char c;
    ss >> a >> c >> b;
    string t = fp_to_bin(b);
    if (a > 255 || t.size() > 4) {
      cout << "NA\n";
    } else {
      while (t.size() < 4) {
        t += "0";
      }
      cout << int_to_bin(a) << "." << t << "\n";
    }
  }
}