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[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);
		}
		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 <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;

#define DBG(x) cerr << #x << " = " << x << endl

template <class T, class U> 
T lexical_cast(const U& from) {
  stringstream ss;
  ss << from;
  T to;
  ss >> to;
  return to;
}

int main() {
  while(true) {
    string s; cin >> s;
    if(s[0] == '-') break;
    string ax, bx;
    for(int i = 0; i < (int)s.size(); ++i) {
      if(s[i] == '.') {
        ax = s.substr(0, i);
        bx= "0." + s.substr(i + 1);
      }
    }
    string as, bs;
    int a = lexical_cast<int>(ax);
    double b = lexical_cast<double>(bx);
    while(a > 0 && as.size() <= 8) {
      as.push_back('0' + a % 2);
      a /= 2;
    }
    reverse(as.begin(), as.end());
    while(abs(b) > 1e-8 && bs.size() <= 4) {
      bs.push_back('0' + (int)(b * 2));
      b *= 2;
      if(b - 1.0 > -1e-8) b -= 1.0;
    }
    if(as.size() <= 8 && bs.size() <= 4) {
      for(int i = 0; i < 8 - as.size(); ++i) cout << "0";
      cout << as << "." << bs;
      for(int i = 0; i < 4 - bs.size(); ++i) cout << "0";
      cout << endl;
    }
    else {
      cout << "NA" << endl;
    }
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
double x;
int main() {
    while(cin >> x, x >= 0) {
        if(x >= 256.0 || fmod(x * 16.0, 1.0) != 0.0) {
            cout << "NA" << endl;
        }
        else {
            int z = x * 16;
            for(int i = 11; i >= 0; i--) {
                if(i == 3) cout << ".";
                if(z & (1 << i)) cout << 1;
                else cout << 0;
            }
            cout << 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];
	double n,s;
	while(1){
		scanf("%lf",&n);
		if(n<0)break;
		n=n*16;
//		printf("%f\n",n);
		if(n-(int)n>0||n>4095){
			printf("NA\n");
		}
		else{
			for(i=0;i<12;i++){
				if(n-a[i]>=0){
					x[i]=1;
					n-=a[i];
				}
				else{
					x[i]=0;
				}
			}
			for(i=0;i<12;i++){
				if(i==8){
					printf(".");
				}
				printf("%d",x[i]);
			}
			printf("\n");
		}
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

double x;

int main(){
	while(cin>>x){
		if(x<0)return 0;
		int n=(x-floor(x))*10000+1e-8;
		if(n%625)cout<<"NA"<<endl;
		else{
			n=x*16+1e-8;
			if(n>4095)cout<<"NA"<<endl;
			else{
				for(int i=0;i<12;i++){
					cout<<(n/(int)(pow(2,11-i)+1e-8))%2;
					if(i==7)cout<<".";
				}
				cout<<endl;
			}
		}
	}
}

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

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int dx[] = { -1, 0, 1, 0 };
int dy[] = {  0, -1, 0, 1 };

int main() {

  loop {
    Real r; cin >> r;
    if (!cin || r < 0) break;

    string s = "";
    range (i, 7, -1) {
      Real f = pow(2.0, i);
      if (r >= f) {
        r -= f;
        s += "1";
      } else {
        s += "0";
      }
    }
    s += ".";
    range (i, -1, -5) {
      Real f = pow(2.0, i);
      if (r >= f) {
        r -= f;
        s += "1";
      } else {
        s += "0";
      }
    }

    if (r < 1e-11) {
      cout << s << endl;
    } else {
      cout << "NA" << endl;
    }

  }

  return 0;
}

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

int main() {
	double y;
	while(cin>>y){
	if (y<0) break;
	y=y*16;
	if(y-(int)y !=0 ) cout<<"NA"<<endl;
	else {
		int z=(int) y;
		if(z>8191) cout<<"NA"<<endl;
		else{
			for(int k=11;k>3;k--){
				int q=z>>k;
					q=q&1;
				cout<<q;
				
			}
			cout<<".";
			for(int k=3;k>-1;k--){
				int q=z>>k;
					q=q&1;
				cout<<q;
				
			}
			cout<<endl;
			
			
			
		}
		
		
		
	}
	
	



	}


}