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>

using namespace std;

int main()
{
    double n;

    while (cin >> n, n != -1.0) {
        int up = (int)n;
        string u, l;
        
        n -= up;
        while (up != 0) {
            u += (up % 2) + '0';
            up /= 2;
        }
        if (u.size() > 8) {
            cout << "NA" << endl;
            continue;
        }
        while (u.size() < 8)
            u += '0';
        reverse(u.begin(), u.end());

        if (n == 0.0)
            l = '0';
        else {
            for (int i = 0; i < 5; i++) {
                n *= 2;
                if ((int)n == 1) {
                    l += '1';

                    if (n - (int)n == 0)
                        break;
                    n -= (int)n;
                }
                else 
                    l += '0';
            }
        }
        if (l.size() > 4) {
            cout << "NA" << endl;
            continue;
        }
        while (l.size() < 4)
            l += '0';
        cout << u << '.' << l << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
double n; long long a, b;
int main() {
	while (true) {
		cin >> n; a = 1.0 * n * 16; b = 1.0*n * (1<<25);
		if (a < 0) { break; }
		if (b % (1<<21) != 0 || n>=256) { cout << "NA" << endl; }
		else {
			for (int i = 11; i >= 4; i--) {
				cout << (a / (int)pow(2, i)) % 2;
			}
			cout << '.';
			for (int i = 3; i >= 0; i--) {
				cout << (a / (int)pow(2, i)) % 2;
			}
			cout << endl;
		}
	}
}

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;
    }
    string b = compute2(m,flag);
    if (flag)cout << a <<"." << b << endl;
    else cout << "NA" << endl;
  }
}

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

using namespace std;

int main()
{
    double n;
    char bin[12]={'0','0','0','0','0','0','0','0','0','0','0','0'};
    double dbin[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>>n;
    while (n>0.0){
        for(int i=0;i<12;i++){
            if(n>=dbin[i]){
                n-=dbin[i];
                bin[i]='1';
            }else{
                bin[i]='0';
            }
        }
        if(n==0.0){
            cout<<bin[0]<<bin[1]<<bin[2]<<bin[3]<<bin[4]<<bin[5]<<bin[6]<<bin[7];
            cout<<'.'<<bin[8]<<bin[9]<<bin[10]<<bin[11]<<endl;
        }else{
            cout<<"NA"<<endl;
        }
        cin>>n;
    }
}

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

int main()
{
	double n;

	cin >> n;

	while (n >= 0) {

		if ((int)n >= 256 || (int)(n * 16) != n * 16)
			cout << "NA" << endl;
		else {
			int a[8];

			int na = (int)n;

			for (int i = 0; i < 8; i++) {
				a[7 - i] = na % 2;
				na /= 2;
			}

			for (int i = 0; i < 8; i++)
				cout << a[i];

			cout << ".";

			double nb = n - (int)n;

			for (int i = 0; i < 4; i++) {
				nb *= 2;
				cout << (int) nb;
				nb -= (int) nb;
			}
			cout << endl;
		}

		cin >> n;
	}

	return 0;
}

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

using namespace std;

int main(void){
	double n;
	while(1){
		string ans = "";
		cin >> n;
		if(n < 0){
			break;
		}
		for(int i = 7;i >= -4;i--){
			if(n >= pow((double)2,(double)i)){
				ans += '1';
				n -= pow((double)2,(double)i);
			}else{
				ans += '0';
			}
			if(i == 0){
				ans += '.';
			}
		}
		if(n == 0){
			cout << ans << endl;
		}
		else{
			cout << "NA" << endl;
		}
	}

	return 0;
}

C++: #include<iostream>
#include<stack>
#include<queue>
using namespace std;
int main(){
	double n,j;
	int i,count;
	bool flag = true;
	stack<int> s;
	queue<int> q;
	while(cin >> n){
		if(n < 0) return 0;
		count = 0;
		i = n; j = n-i;
		while(i > 3 && count <= 8){
			s.push(i%2);
			i/=2;
			count++;
		}
		if(count > 8)
			flag = false;
		s.push(i%2);
		s.push(i/2);
		count += 2;
		for(int x=count; x<8; x++)
			s.push(0);
		count=0;
		
		while( j != 1.0  && count <= 4){
			q.push(j*2);
			j *= 2;
			if(j > 1)
				j -= 1;
			count++;
		}
		if(count > 4)
			flag=false;
		for(int x=count; x<4; x++)
			q.push(0);

		if(flag == true){
			int size=s.size(), size1=q.size();
			for(int x=0; x<size; x++){
				cout << s.top();
				s.pop();
			}
			cout << '.';
			for(int x=0; x<size1; x++){
				cout << q.front();
				q.pop();
			}
			cout << endl;

		}
		else{
			cout << "NA" << endl;
		}
		
	}

	return 0;
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

bool func();

int main()
{
	while(func()){};
	
	return false;
}

bool func()
{
	while(true)
	{
		double n = 0.0;

		cin >> n;

		if(n < 0)
		{
			return false;
		}

		double tmpi = 0;
		double d = 0; // 整数部格納
		double doubl_e = modf(n, &d); // 小数部格納
		int in_t = d;

		for(int i = 0; true; i++)
		{
			if(i > 8)
			{
				cout << "NA" << endl;
				return true;
			}

			tmpi += (in_t % 2) * pow(10, (double)i);
		
			in_t /= 2;


			if(in_t == 0)
			{
				break;
			}
		}

		int spi = 0;

		for(spi = 1; true; spi++)
		{
			if(spi >= 5)
			{
				cout << "NA" << endl;
				return true;
			}

			doubl_e *= 2;

			if(doubl_e >= 1)
			{
				doubl_e -= 1;
				tmpi += 1 * pow(10, (double)-spi);
			}

			if(doubl_e == 0)
			{
				break;
			}
		}
		
		for(unsigned long int i = 10000000; true; i /= 10)
		{
			if(tmpi / i <= 1)
			{
				cout << '0';
			}
			else
			{
				break;
			}
		}

		printf("%.4lf\n",  tmpi);

	}
}

C++: // 2012/08/08 Tazoe

#include <iostream>
using namespace std;

void conv(int n, int p)
{
	if(p==0)
		return;

	conv(n/2, p-1);

	if(p==9){
		cout << '.';
	}
	cout << n%2;
}

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||n16>=4096){
			cout << "NA" << endl;
			continue;
		}

		conv(n16, 12);
		cout << endl;
	}

	return 0;
}