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, m;
	char c;
	while(scanf("%d.%d", &n, &m)){
		if(n < 0)break;
		if(n > 511 || m > 880){
			cout << "NA" << endl;
			continue;
		}
		bitset<8> re(n);
		int cnt = 0;
		if(m % 5 != 0){
			cout << "NA" << endl;
			continue;
		}
		while(1){
			if(m == 1)break;
			m /= 5;
			cnt++;
		}
		bitset<4> im(cnt);
		cout << re << ".";
		for(int i = 0; i < 4; i++)
			cout << im[i];
		cout << 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>
using namespace std;
int main(){
	float n, hiku = 0, a = 1;
	float n1, n2;//??´??°????°???°
	int count=0, end = 0; // ???????????????N?????°
	int nn1[8] = { 0 }, nn2[4] = { 0 };//??´??°??¨????°???°??¨
	cin >> n;
	while (n >= 0){
		n1 = n;
		while (n >= 1) n = n - a;
		n2 = n; n1 = n1 - n2;// ??´??°??¨?°???°???????????????
		// 1 //?°???°???????????°????????????
		if (n2 != 0){
			while (1){
				n2 = n2 * 2;
				if (n2 >= 1) {
					nn2[count] = 1;
					n2 = n2 - 1;
				}
				if (n2 == 0) break;
				count++;
				if (count >= 4){
					cout << "NA" << endl; //?????????
					end = 1; //N?????°
					break;
				}
			}
		}count = 0;
		int nnn;
		nnn = n1;
		if (end == 0){
			while (1){
				hiku = nnn / 2;
				if (nnn - (hiku * 2) == 1) nn1[count] = 1;
				count++;
				nnn = nnn / 2;
				if (nnn == 0) {
					nn1[count] = 0;
					break;
				}
				else if (nnn == 1) {
					nn1[count] = 1;
					break;
				}
				if (count >= 8){
					cout << "NA" << endl;
					end = 1;
					break;
				}
			}
		}
		if (end == 0){
		for (int i = 7; i >= 0; i--) cout << nn1[i];
		cout << ".";
		for (int i = 0; i < 4; i++) cout << nn2[i];
		cout << endl;
	}
		count = 0;
		for (int i = 7; i >= 0; i--)nn1[i] = 0;
		for (int i = 0; i < 4; i++)nn2[i] = 0;
		end = 0;
		cin >> n;
	}
 	return 0;
}

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(decDecimal!=0.0){
		decDecimal = (decDecimal-floor(decDecimal))*2;
		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>
using namespace std;
int main(){
	double n;
	while(true){
		cin>>n;
		if(n<0.0)break;
		bool na=false;
		if(n>128.0)na=true;
		int x=n/(0.25*0.5);
		if(x*(0.25*0.5)!=n)na=true;
		if(na==true)
			cout<<"NA"<<endl;
		else{
		int bit=n*16;
		int ans[12];
		for(int j=0;j<12;j++)
			ans[j]=(bit>>j)&1;
		for(int j=11;j>=0;j--){
			cout<<ans[j];
			if(j==4)cout<<".";
		}
		cout<<endl;
		}
	}
	return 0;
}

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

int main()
{
	while (true){
		double n;
		cin >> n;
		if (n < 0) break;
		bool j[12];
		memset(j, false, sizeof j);

		for (int i = 0; i < 12; i++){
			if (n >= (double)128 / (1 << i)){
				j[i] = true;
				n -= (double)128 / (1 << i);
			}
		}
		if (!n){
			for (int i = 0; i < 12; i++){
				if (i == 8) cout << ".";
				cout << j[i];
			}
			cout << endl;
		}
		else cout << "NA" << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
int main()
{
	int i, t, u;
	double n, a, b, x, y;
	while (cin >> n && n >= 0.0)
	{
		char c[14] = "        .    ";
		b = modf(n, &a);
		t = (int)a;
		for (i = 7; i >= 0; i--)
		{
			c[i] = ((t % 2 == 0) ? '0' : '1');
			t /= 2;
		}
		if (t > 0)
		{
			cout << "NA" << endl;
			continue;
		}
		for (i = 9; i <= 12; i++)
		{
			b *= 2;
			y = modf(b, &x);
			c[i] = ((x == 0.0) ? '0' : '1');
			b = y;
		}
		if (y != 0.0)
			cout << "NA" << endl;
		else
			cout << c << endl;
	}
}

C++: // 2011/07/20 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);		// 16{µÄC¬_ÈºØèÌÄ
		if(n*16.0!=(double)n16||n16>=4096){	// §ÀÉûÜçÈ¢ê
			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++: // AOJ 0220
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
	double n;
	while (cin >> n, n >= 0){
		string ret;
		int a = (int)n;
		while (a != 0){
			if (a == 1){
				ret += '1';
				break;
			}
			if (a % 2 == 0){
				a /= 2;
				ret += '0';
			}
			else {
				a /= 2;
				ret += '1';
			}
		}
		// cout << ret.length() << endl;
		for (int i = ret.length(); i < 8; i++) ret += '0';
		// cout << ret.length() << endl;
		reverse(ret.begin(), ret.end());
		ret += '.';

		string ret2;
		int cnt = 0;
		bool f = true;
		n -= (int)n;
		while (n != 0){
			if (cnt > 4){
				f = false;
				break;
			}
			n *= 2.0;
			if (n >= 1.0){
				ret2 += '1';
				n -= 1.0;
			}
			else {
				ret2 += '0';
			}
			// cout << n << endl;
			cnt++;
		}
		for (int i = ret2.length(); i < 4; i++) ret2 += '0';
		// reverse(ret2.begin(), ret2.end());

		// cout << ret << ret2 << endl;
		if (!f){
			cout << "NA" << endl;
		}
		else {
			cout << ret << ret2 << endl;
		}
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
void convert(int x, int p){
    if ( p == 12 ) return;
    convert(x/2, p+1);
    if ( p == 3 ) cout << ".";
    cout << x%2;
}
int main(){
    for ( double x; cin >> x && x >= 0; ){
        int shift = (int)(x*16);
        if ( x == shift/16.0 && shift < 4096 ){
            convert(shift, 0);
            cout << endl;
        } else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

C++: #include<iostream>
main(){for(double d;std::cin>>d,d>=0;)if(d>=256||d*256-(int)(d*256))puts("NA");else{d/=128;for(int i=0;i++<12;d*=2,i-8||printf("."))std::cout<<(int)d%2;puts("");}}