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<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;
				}
			}
			if(m)ok=false;
		}
		if(ok)cout<<to_b(n,8)<<'.'<<to_b(b,4)<<endl;
		else cout<<"NA\n";
	}
	return 0;
}

C++: #include<iostream>
#include<string>

using namespace std;

int main()
{
	int i,j;
	double n;
	
	for(;;)
	{
		cin >> n;
		if(n<0.0)
			break;
		
		if(n>=256.0)
			cout << "NA" << endl;
		
		string str1,str2;
		int a=(int)n;
		n-=(double)a;
		
		for(i=128;i>0;i/=2)
		{
			if(i<=a)
			{
				str1+="1";
				a-=i;
			}
			else
				str1+="0";
		}
		for(double a=2.0,j=0;j<4;a*=2,j++)
		{
			if(1.0/a<=n)
			{
				str2+="1";
				n-=1/a;
			}
			else
				str2+="0";
		}
		if(n==0.0)
		{
				cout << str1 << "." << str2 << endl;
		}
		else
			cout << "NA" << endl;
	}
}

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

string decToBin(float n){
	string binInteger, binDecimal;
	int decInteger;
	float decDecimal;
	ostringstream oss;
	
	decInteger = floor(n);
	decDecimal = n - decInteger;
	
	while(decInteger){
		binInteger += '0'+(decInteger%2);
		decInteger /= 2;
	}
	reverse(binInteger.begin(),binInteger.end());
	if(binInteger.length()>8)return "NA";
	
	while(1){
		decDecimal = (decDecimal-floor(decDecimal))*2;
		if(decDecimal==0.0)break;
		binDecimal += '0'+floor(decDecimal);
	}
	if(binDecimal.length()>4)return "NA";

	oss<<setfill('0')<<setw(8)<<binInteger
	<<"."
	<<left<<setw(4)<<binDecimal;
	
	return oss.str();
}

int main() {
	float n;
	while(cin>>n,n>=0.0){
		cout<<decToBin(n)<<endl;
	}
	return 0;
}

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

const double EPS = 1e-10;
double b[] = {0.0625, 0.125, 0.25, 0.5};

int main()
{
  double n;
  while (cin >> n) {
    if (n < 0.0)
      break;

    vector<int> digit;
    int d = static_cast<int>(n);
    int dd = d;
    while (dd > 0) {
      digit.push_back(dd%2);
      dd /= 2;
    }
    while (digit.size() < 8)
      digit.push_back(0);

    if (digit.size() > 8) {
      cout << "NA" << endl;
      continue;
    }
    reverse(digit.begin(), digit.end());

    bool found = false;
    for (int i = 0; i < (1 << 4) && !found; ++i) {
      double r = 0.0;
      for (int j = 0; j < 4; ++j) {
	if (i & (1 << j))
	  r += b[j];
      }

      if (abs(d + r - n) < EPS) {
	for (int j = 0; j < 8; ++j)
	  cout << digit[j];
	cout << ".";
	for (int j = 0; j < 4; ++j) {
	  if (i & (1 << (3-j)))
	    cout << "1";
	  else
	    cout << "0";
	}
	cout << endl;
	found = true;
      }
    }

    if (!found)
      cout << "NA" << endl;
  }
  return 0;
}

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

int toInt(const string &s){
  stringstream ss;
  ss<<s;
  int a;
  ss>>a;
  return a;
}

int main(void){
  string s;
  while(cin>>s){
    string p,q;
    if(s.find('.')!=-1){p=s.substr(0,s.find('.'));q=s.substr(s.find('.')+1,s.size()-s.find('.'));}
    else p=s;
    while(q.size()<4)q+='0';
    int pp=toInt(p),qq=toInt(q);if(pp<0)break;
    vector<int> a,b;
    for(int i=0;i<4;++i){
      b.push_back((qq*2/10000)?1:0);
      qq=(qq*2)%10000;
    }
    if(qq)cout<<"NA"<<endl;
    else{
      for(int i=0,t=1<<8;i<8;++i){
        a.push_back((pp/t)?1:0);
        pp=pp-pp/t;
        t/=2;
      }
      for(int i=0;i<8;++i)cout<<a[i];
      cout<<".";
      for(int i=0;i<4;++i)cout<<b[i];
      cout<<endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <cstring>

using namespace std;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

int ans[12];

int main(){
	double n;
	
	while (cin >> n, n != -1.0){
		n *= 16;
		
		int na = n;
		
		int flag = 1;
		
		REP(i,12){
			ans[i] = 0;
		}
		
		if (n >= 4096){
			flag = 0;
		}
		
		if ((double)na != n){
			flag = 0;
		}
		
		int base = 128*16;
		
		if (flag){
			REP(i,12){
				if (base <= na){
					ans[i] = 1;
					na -= base;
				}
				if (i == 11 && na){
					flag = 0;
				}
				base /= 2;
			}
		}
		
		if (flag){
			REP(i,12){
				printf("%d", ans[i]);
				if (i == 7){
					printf(".");
				}
			}
			puts("");
		}
		else {
			puts("NA");
		}
	}
	
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;




const int INF = 1000000;
const int mod = 1e9 + 7;


string tobi(int n, int d){
	string ret(d, '0');
	int i = 0;
	while(n > 0){
		ret[i] += n % 2;
		n /= 2;
		i++;
		if(i >= d) return "f";
	}
	reverse(all(ret));
	return ret;
}

string tobi2(double n){
	string ret(4, '0');
	for(int i = 0; i < 4; i++){
		n *= 2;
		ret[i] += (int)n % 2;
		n -= ret[i] - '0';
	}
	if(n != 0.0) return "f";
	return ret;
}

int main(){
	string s;
	while(cin>>s){
		if(s[0] == '-') break;
		string t, u = "0";
		if(s.find(".") == string::npos) t = s, u = "0";
		else {
			t = s.substr(0, s.find("."));
			u += s.substr(s.find("."));
		}

				
		t = tobi(atoi(t.c_str()), 8);
		u = tobi2(atof(u.c_str()));


		if(t == "f" || u == "f") {
			cout<<"NA"<<endl;
			continue;
		}

		cout<<t<<"."<<u<<endl;
	}

}

C++: #include<iostream>
#include<vector>
int de[8] = {128,62,32,16,8,4,2,1};
double dou[4] = {0.5,0.25,0.125,0.0625};

using namespace std;

int main(void){
  double in;
  while(cin>>in,in){
    vector<int> ans(12,0);
    bool used = false;
    for(int i = 0 ; i < 8 ; i ++){
      if(in>de[i]){
          ans[i] = 1;
          in -= de[i];
          used = true;
      }
    }
    for(int i = 0 ; i < 4 ; i ++){
      if(in>dou[i]){
        if(in>dou[i]){
          ans[i+8] = 1;
          in -= dou[i];
          used = true;
        }
      }
    }
    if(used && in == 0){
      for(int i = 0 ; i < 8 ; i ++)
        cout<<ans[i];
      cout<<".";
      for(int i = 8 ; i < 12 ; i ++)
        cout<<ans[i];
      cout<<endl;
    }else 
      cout<<"NA"<<endl;
    
    
  }
}