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 <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();
}

C++: #include<iostream>
#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;
}

string compute2(int m,bool &flag){
  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];
    }
    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;
  while(getline(cin,in) && in[0] != '-'){
    bool isper=false;
    rep(i,in.size())if (in[i] == '.'){
      isper=true;
      in[i]=' ';
    }
    stringstream sin(in);
    if (isper)sin>>n>>m;
    else sin>>n,m=0;

    m*=1000;
    bool flag;
    string a=compute(n,flag);
    if (!flag){
      cout << "NA" << endl;
    }
    string b = compute2(m,flag);
    if (flag)cout << a <<"." << b << endl;
    else cout << "NA" << endl;
  }
}

C++: #include<stdio.h>
int main(){
	double a;
	while(scanf("%lf",&a)){
		if(a<0)return 0;
		int b=a*16;
		if(a*16-(double)b>0.0f||a>=4096){
			printf("NA\n");
		}else{
			for(int i=11;i>=4;i--){
				printf("%d",b%(1<<(i+1))/(1<<(i)));
			}
			printf(".");
			for(int i=3;i>=0;i--){
				printf("%d",b%(1<<(i+1))/(1<<(i)));
			}
			printf("\n");
		}
	}
}

C++: #include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
	ios::sync_with_stdio(false);
int main(){
	double n;

		//for(int i=0;i<ans.size();i++)cout<<ans[i]<<" ";cout<<endl;
	while(cin>>n){
	if(n<0)break;
	vector<bool>ans(0);
	queue< vector<bool> >bfs;
	bfs.push(ans);
	while(!bfs.empty()){
		vector<bool>tmp=bfs.front();
		bfs.pop();
		if(tmp.size()>12){
		cout<<"NA"<<endl;
		break;
		}
		double sum=0;
		for(int i=0;i<min(8,(int)tmp.size());i++)if(tmp[i])sum+=pow(2,7-i);
		for(int i=0;i<min(4,(int)tmp.size()-5);i++)if(tmp[8+i])sum+=pow(2,-1*(i+1));
		if(sum==n){
		int cnt=0;
		for(int i=0;i<tmp.size();i++){
		cout<<tmp[i];
		if(cnt==7)cout<<'.';
		cnt++;
		}
		for(int i=0;i<12-tmp.size();i++){
		cout<<'0';
		if(cnt==7)cout<<'.';
		cnt++;
		}
		cout<<endl;
		break;
		}
		tmp.push_back(0);
		bfs.push(tmp);
		tmp.erase(tmp.begin()+(tmp.size()-1));
		tmp.push_back(1);
		bfs.push(tmp);
	}
	}
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

int main() {
  while( true ) {
	double n;
	cin >> n;
	if ( n == -1.0 ) break;

	int m = (int)( n * 16 );
	if ( n * 16 - m > 0 ) {
	  cout << "NA" << endl;
	} else {
	  for ( int i = 7; i >= 0; i-- ) {
		if ( ( 1 << ( i + 4 ) ) & m ) {
		  cout << 1;
		} else {
		  cout << 0;
		}
	  }
	  cout << ".";
	  for ( int i = 3; i >= 0; i-- ) {
		if ( ( 1 << i ) & m ) {
		  cout << 1;
		} else {
		  cout << 0;
		}
	  }
	  cout << endl;
	}	
  }
}

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const double LIM = (1 << 8);

string calc2(double N) {
  stringstream ss;
  for(int i = 0; N != 0.0 && i < 10; ++i){
    double nn = N * 2;
    if(nn >= 1.0){
      ss << 1;
      nn -= 1.0;
    }
    else ss << 0;
    N = nn;
  }
  while(ss.str().length() < 4) ss << 0;
  string s = ss.str();
  return (s.length() == 4 ? s : "NA");
}

string calc(int N) {
  stringstream ss;
  while(N){
    if(N & 1) ss << 1;
    else ss << 0;
    N >>= 1;
  }
  while(ss.str().length() < 8) ss << 0;
  string s = ss.str();
  REVERSE(s);
  return (s.length() == 8 ? s : "NA");
}

int main() {
  double N;
  while(cin >>N && N >= 0.0) {
    string a = calc(floor(N)), b = calc2(N - floor(N));
    if(a == "NA" || b == "NA") {
      cout <<"NA" <<endl;
      continue;
    }
    cout <<a + "." + b <<endl;
  }
  return 0;
}

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

int to_i(string s){
	int res=0;
	for(int i=0;i<s.size();i++){
		res*=10;
		res+=s[i]-'0';
	}
	return res;
}
string to_b(int n,int d){
	string s;
	for(int i=0;i<d;i++){
		s+=((n>>d-i-1)&1)+'0';
	}
	return s;
}

int main(){
	string s;
	while(cin>>s&&s[0]!='-'){
		bool ok=true;
		int p=s.find('.',0);
		if(p==string::npos){
			p=s.size()+1;
			s+=".0000";
		}
		else p++;
		if(p+4>s.size()){
			s.append(p+4-s.size(),'0');
		}
		int n=to_i(s.substr(0,p-1));
		if((n&((1<<8)-1)) !=n )ok=false;
		int b=0;
		if(ok){
			int m=to_i(s.substr(p,s.size() ));
			int a=5000;
			for(int i=0;i<4;i++){
				if(a<=m){
					m-=a;
					b|=1<<3-i;
					a/=2;
				}
			}
			if(m)ok=false;
		}
		if(ok)cout<<to_b(n,8)<<'.'<<to_b(b,4)<<endl;
		else cout<<"NA\n";
	}
	return 0;
}