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

#define EPS (1e-8)
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EQ(a,b) (abs(a-b)<EPS)
#define pb push_back

double n;

string i2s(int i) {
  stringstream ss;
  ss<<i;
  return ss.str();
}

void solve() {
  int real; double imag = n;
  real = (int)imag;
  imag -= (double)real;
  string re, im;
  
  // real
  while (1) {
    if (real / 2 == 0) {
      re.insert(0, "1");
      break;
    }
    if (real % 2) {
      re.insert(0, "1");
    } else {
      re.insert(0, "0");
    }
    real /= 2;
  }
  
  // imag
  vector<double> ds;
  ds.pb(imag);
  while (1) {
    imag *= 2;
    
    bool flag = false;
    rep(i,ds.size()) if (EQ(imag, ds[i])) flag = true;
    if (flag) break;
    
    ds.pb(imag);
    if (imag >= 1.0) {
      im += "1";
      imag -= 1.0;
    } else {
      im += "0";
    }
  }
  if (re.size() > 8 || im.size() > 4) {
    cout<<"NA"<<endl; return;
  }
  while (im.size()!=4) im+="0";
  while (re.size()!=8) re.insert(0,"0");
  cout<<re<<"."<<im<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    if (EQ(n, -1.0)) break;
    solve();
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  int n,m;
  while(scanf("%d",&n), n >= 0){
    string ans;

    if(getchar() == '.') scanf("%d",&m);
    else m = 0;

    if( n > 255 ) ans = "NA";
    else{
      REP(i,8){
	if(n & (1 << i))
	  ans = "1" + ans;
	else
	  ans = "0" + ans;
      }

      ans += ".";
      if(m != 0)
	while(m*10 < 10000) m *= 10;

      REP(i,4){
	m *= 2;
	if( m >= 10000 ){
	  ans = ans + "1";
	  m -= 10000;
	}else{
	  ans = ans + "0";
	}
      }
      if( m != 0 ) ans = "NA";
    }
    cout << ans << endl;
  }
  return 0;
}

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

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

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

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;
const double EPS  = 1e-10;

int main() {
	map<int, string> ma, mb;
	REP(i, 1<<8) {
		string str = "";
		int sum = 0;
		
		REP(j, 8) {
			if (i >> j & 1) sum += 1<<j;
			str += '0' + (i >> j & 1);
		}
		
		reverse(ALL(str));
		ma[sum] = str;
	}
	
	int num[4] = {5000, 2500, 1250, 625};
	REP(i, 1<<4) {
		string str = "";
		int sum = 0;
		
		REP(j, 4) {
			if (i >> j & 1) sum += num[j];
			str += '0' + (i >> j & 1);
		}
		mb[sum] = str;
	}
	
	string str;
	while (cin >> str, str[0] != '-') {
		string A = str.substr(0, str.find('.'));
		string B = str.substr(str.find('.') + 1, str.size());
		while (B.size() < 4) B += '0';
		
		int a = atoi(A.c_str()), b = atoi(B.c_str());
		
		if (ma.find(a) == ma.end() || mb.find(b) == mb.end()) puts("NA");
		else cout << ma[a] << "." << mb[b] << endl;
	}
	
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(void){

  double n;
  while( cin >> n , n > 0 ){

    if( n >= 256 ){
      cout << "NA" << endl;
      continue;
    }

    int l[8],r[4];
    int N = n;
    n = n - N;
    for( int i = 7 ; i >= 0 ; i-- ){
      l[i] = N % 2;
      N /= 2;
    }

    for( int i = 0 ; i < 4 ; i++ ){
      r[i] = n * 2;
      n *= 2;
      int t = n;
      n = n - t;
    }
    if( n != 0 ){
      cout << "NA" << endl;
      continue;
    }

    for( int i = 0 ; i < 8 ; i++ )
      cout << l[i];
    cout << '.';
    for( int i = 0 ; i < 4 ; i++ )
      cout << r[i];
    cout << endl;

  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  int n,m;
  while(scanf("%d.%d",&n,&m), n >= 0){
    string ans;

    if( n > 255 ) ans = "NA";
    else{
      REP(i,8){
	if(n & (1 << i))
	  ans = "1" + ans;
	else
	  ans = "0" + ans;
      }

      ans += ".";
      if(m != 0)
	while(m*10 < 10000) m *= 10;

      REP(i,4){
	m *= 2;
	if( m >= 10000 ){
	  ans = ans + "1";
	  m -= 10000;
	}else{
	  ans = ans + "0";
	}
      }
      if( m != 0 ) ans = "NA";
    }
    cout << ans << endl;
  }
  return 0;
}

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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  char buf[256];
 
  while(1){

    int a=0;
    double b=0;

    fgets(buf,sizeof(buf),stdin);
    sscanf(buf,"%d%lf",&a,&b);

    if(a<0){
      break;
    }
      
    int temp=128;
    int ans[8]={ };
    for(int i=0;i<8;i++){

      if(a>=temp){
	a-=temp;
	ans[i]=1;
      }
      temp/=2;
    }

    double tmp=0.5;

    int ans1[4]={ };
    for(int i=0;i<4;i++){
      if(b>=tmp){
	b-=tmp;
	ans1[i]=1;
      }
      tmp/=2;
    }

    if(a==0&&b==0){

      for(int i=0;i<8;i++){
	cout<<ans[i];
      }
      cout<<".";
      for(int i=0;i<4;i++){
	cout<<ans1[i];
      }
      cout<<endl;
    }else{
      cout<<"NA"<<endl;
    }

  }
  

  return 0;

}