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 <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <unordered_set>
//#include <unordered_map>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	double n;
	while(cin>>n,n>=0.0){
		int a=n;
		n-=a;
		// cout<<a<<" "<<n<<endl;
		bool f1=false;
		bool f2=false;
		if(a<(1<<8)) f1=true;
		if(n==0.0) f2=true;
		stringstream ss;
		rep(i,4){
			n*=2.0;
			if(n==1.0){
				ss<<'1';
				n=0.0;
				f2=true;
			}
			else if(n>1.0){
				n-=1.0;
				ss<<'1';
			}
			else{
				ss<<'0';
			}
		}
		stringstream ss1;
		if(f1&&f2){
			string s1;
			ss>>s1;
			rep(i,8){
				if(a&1){
					ss1<<'1';
					// cout<<1;
				}
				else{
					ss1<<'0';
					// cout<<0;
				}
				a>>=1;
			}
			string s2;
			ss1>>s2;
			// cout<<s2<<endl;
			reverse(ALL(s2));
			cout<<s2<<"."<<s1<<endl;
		}
		else{
			cout<<"NA"<<endl;
		}
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

C++: #include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rrep(i,n) for(int i=(int)(n)-1; i>=0; i--)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000001;
const ll MAXL=1000000000000000001LL;
const ll mod=1000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

map<double,string> m;

void make(string s) {
  if(s.size()==12) {
    double a=(1<<7);
    double sum=0;
    rep(i,s.size()) {
      if(s[i]=='1') sum+=a;
      a/=2;
    }
    m[sum]=s.substr(0,8)+'.'+s.substr(8);
  } else {
    make(s+'0');
    make(s+'1');
  }
}

int main() {
  make("");
  double x;
  while(cin >> x && x!=-1.0) {
    if(m.count(x)) pr(m[x]);
    else pr("NA");
  }
  return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>
#define EPS 0.000001
using namespace std;

double n;

int I;

double D;

int integer[8];
int decimal[4];


bool judge(double a){
	return (a - (int)a < EPS);
}


int Ifunction(int I,int l)
{
	int i = 7;

	int cnt = 0;

	while (I != 0)
	{
		
		if (cnt>=l)
		{
			return 0;
		}

		integer[i--] = I % 2;

		I = I / 2;

		cnt++;
	}
}

void DIfunction(int I,int a)
{
	int i = a-1;

	while (I!=0)
	{
		decimal[i++] = I % 2;

		I = I / 2;
	}
}

void D2function(double D)
{
	int i = 0;

	int cnt = 0;

	int k = -1;

	while (i!=4)
	{
	
		if (D - pow(2, k) >= 0)
		{
			decimal[i] = 1;

			D -= pow(2, k);

		}

		i++;

		k--;
	}

	
}

int Dfunction(double D)
{
	int cnt = 1;

	while (!judge(D))
	{

		if (cnt > 4)
		{
			return 0;
		}

		D *= 2;

		cnt++;

	}

	return cnt;
}

int main(void)
{
	while (cin >> n, n>=0)
	{
		I = n;

		D = n - I;

		int cnt1 = 1;
		int cnt2 = 1;

		cnt1 = Ifunction(I,8);

		cnt2 = Dfunction(D);

		if (cnt1==0||cnt2==0)
		{
			cout << "NA" << endl;

			fill(&integer[0], &integer[8], 0);
			fill(&decimal[0], &decimal[4], 0);

			continue;
		}
		else
		{
			for (int i = 0; i < 8;i++)
			{
				cout << integer[i];
			}

			cout << ".";

			int flag = D*pow(2, cnt2);

			D2function(D);

			//DIfunction(flag,cnt2);

			for (int i = 0; i < 4; i++)
			{
				cout << decimal[i];
			}

			cout << endl;
		}

		fill(&integer[0], &integer[8], 0);
		fill(&decimal[0], &decimal[4], 0);

	}

	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;
	double list[4] = {0.5, 0.25, 0.125, 0.0625};
	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 > 255 || sm.length() > 4){
			cout << "NA" << endl;
			continue;
		}
		bitset<8> re(n);

		int d[4] = {0};
		double d_ans = 0.5;

		string s;
		rep(i, 4){
			if(m >= list[i]){
				m -= list[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();
}