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<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;
    int m=0;
    int cnt=0;
    rep(i,in.size()){
      if (in[i] == '.'){
	isper=true;
	in[i]=' ';
      }else if (isper){
	m=m*10+(in[i]-'0');
	cnt++;
      }
    }
    for(;cnt<4;cnt++)m*=10;
    
    stringstream sin(in);
    sin>>n;



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

C++: #include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main() {
	double n, over = 255, under[4] = {0.5, 0.25, 0.125, 0.0625};
	rep(i, 4) over += under[i];
	while(cin >> n, n != -1.0) {
		double sum = 0;
		vector<char> ans;
		if(n > over) cout << "NA" << endl;
		else {
			for(int i = 7; i > -1; --i) {
				if(sum + (1 << i) <= n) {
					sum += (1 << i);
					ans.push_back('1');
				}
				else ans.push_back('0');
			}
			ans.push_back('.');
			rep(i, 4) {
				if(sum + under[i] <= n) {
					sum += under[i];
					ans.push_back('1');
				}
				else ans.push_back('0');
			}
			if(sum == n) rep(i, ans.size()) cout << ans[i];
			else cout << "NA";
			cout << endl;
		}
	}
}

C++: #include<stdio.h>
int main(void){
	double n,syo;
	int sei,ans[12],i;
	for(i=0;i<12;i++){
		ans[i]=0;
	}
	while(1){
		scanf("%lf",&n);
		if(n==-1.0)
			break;
		sei=128;
		for(i=11;i>3;i--){
			if(n>=sei){
				ans[i]=1;
				n-=sei;
			}
			else {
				ans[i]=0;
			}	
			sei/=2;
		}
		if(n>=1.0){
			printf("NA\n");
		}
		else {
			syo=0.5;
			for(i=3;i>=0;i--){
				if(n>=syo){
					ans[i]=1;
					n-=syo;
				}
				else {
					ans[i]=0;
				}
				syo/=2.0;
			}
			if(n>0.0){
				printf("NA\n");
			}
			else {
				for(i=11;i>=0;i--){
					if(i==3){
						printf(".");
					}
					printf("%d",ans[i]);
				}
				printf("\n");
			}
		}
	//	syo=0.5;
	}
	return 0;
}

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

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	double dec;
	int itg;
	int ans1[16], ans2[8];
	
	while(scanf("%lf",&dec))
	{

		memset(ans1, 0, sizeof(ans1));
		memset(ans2, 0, sizeof(ans2));

		if(dec < 0)
		{
			break;
		}
		
		itg = (int)dec;
		dec -= itg;

		for(int i = 7; i >= 0; i--)
		{
			ans1[i] = itg%2;
			itg /= 2;
		}
		for(int i = 0; i < 4; i++)
		{
			dec *= 2;
			if(dec >= 1)
			{
				ans2[i] = 1;
				dec -= 1;
			}
		}

		if(!itg && !dec)
		{
			for(int i = 0; i < 8; i ++)
			{
				printf("%d", ans1[i]);
			}
			printf(".");
			for(int i = 0; i < 4; i++)
			{
				printf("%d", ans2[i]);
			}
			puts("");
		}
		else
		{
			printf("NA\n");
		}
	}
}

C++: // 2010/12/23 Tazoe

#include <iostream>
using namespace std;

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

		int n16 = (int)(n*16.0);
		if(n*16.0!=(double)n16){
			cout << "NA" << endl;
			continue;
		}

		int bin[12];
		for(int i=0; i<12; i++){
			bin[i] = n16%2;
			n16 /= 2;
		}

		for(int i=11; i>=4; i--)
			cout << bin[i];
		cout << '.';
		for(int i=3; i>=0; i--)
			cout << bin[i];
		cout << endl;
	}

	return 0;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main(void)
{
	double a;
	int i;
	int box[12]={0,0,0,0,0,0,0,0,0,0,0,0};
	double nisin[12]={128.0,64.0,32.0,16.0,8.0,4.0,2.0,1.0,0.5,0.25,0.125,0.0625};

	cin >> a;
	while(a>0.0){
		for(i=0;i!=12;i++){
			if(a>=nisin[i]){
				a=a-nisin[i];
				box[i]=1;
			}
		}
		if(a==0.0){
			for(i=0;i!=12;i++){
				cout << box[i];
				if(i==7){
					cout << '.';
				}
			}
		}
		else{ 
			cout << "NA";
		}
		cout << endl;
		cin >> a;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  double n;
  while(cin>>n){
    if(n<0) break;
    n *= 16;
    if(n==(int)n){
      int num = (int)n;
      vector<int> bit(12);
      REP(i,12){
        bit[i] = num%2;
        num/=2;
      }
      reverse(bit.begin(),bit.end());
      REP(i,8){
        cout<<bit[i];
      }
      putchar('.');
      REP(i,4){
        cout<<bit[8+i];
      }
      putchar('\n');
    }else{
      cout<<"NA"<<endl;
    }
  }
  return 0;
}