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<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int a[10],i,x,b[10];
  double n,z,y;
  while(1){
    scanf("%lf\n",&n);
    if(n<0){
      return 0;
    }
    x=n;
    z=x;
    y=n-z;
    if(x>=256 || y>0.9375){
      printf("NA\n");
      continue;
    }
    for(i=0;i<8;i++){
      a[i]=0,b[i]=8;
    }
    for(i=0;i<8;i++){
      a[i]=x%2;
      x=x/2;
    }
    for(i=0;i<4;i++){
      y=y*2;
      x=y;
      b[i]=x;
      if(y>=1.00000){
        y=y-1.00000;
      }
    }
    if(y>0.00000){
      printf("NA\n");
      continue;
    }
    for(i=7;i>=0;i--){
      printf("%d",a[i]);
    }
    printf(".");
    for(i=0;i<4;i++){
      printf("%d",b[i]);
    }
    printf("\n");
  }
  return 0;
}

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){	// §ÀÉûÜçÈ¢ê
			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 <cmath>
#include <algorithm>
#include <stack>
#include <queue>

using namespace std;

int main(){

	char ans_upper[9],ans_under[5];
	int upper,under,S;
	double number;

	while(true){
		scanf("%lf",&number);
		if(number < 0)break;

		upper = (int)round(number);

		if(upper >= 256){
			printf("NA\n");
			continue;
		}

		S = 128;

		for(int i = 0; i < 8; i++){
			if(upper >= S){
				ans_upper[i] = '1';
				upper -= S;
			}else{
				ans_upper[i] = '0';
			}
			S /= 2;
		}

		ans_upper[8] = '\0';


		under = 10000*(number - (int)round(number));

		for(int i = 0; i < 4; i++){
			under *= 2;
			if(under/10000 >= 1){
				ans_under[i] = '1';
			}else{
				ans_under[i] = '0';
			}
			under %= 10000;
		}

		if(under != 0){
			printf("NA\n");
			continue;
		}

		ans_under[4] = '\0';

		printf("%s.%s\n",ans_upper,ans_under);

	}

	return 0;
}

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

using namespace std;

int main()
{
	for(char buf[1024];fgets(buf,1024,stdin),buf[0]!='-';){
		double x; sscanf(buf,"%lf",&x);
		
		if(x>=256){
			puts("NA");
			continue;
		}
		if(fmod(x*16,1)>0){
			puts("NA");
			continue;
		}
		int a=x,b=fmod(x,1)*16;
		for(int i=0;i<8;i++)
			putchar('0'+(a>>7-i&1));
		putchar('.');
		for(int i=0;i<4;i++)
			putchar('0'+(b>>3-i&1));
		putchar('\n');
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    vector< pair<double,string> > num;
    double d[] = {0.5,0.25,0.125,0.0625};
    REP(i,2){
	REP(j,2){
	    REP(k,2){
		REP(l,2){
		    num.PB( pair<double,string>(i*d[0] + j*d[1] + k*d[2] + l*d[3],to_string(i)+to_string(j)+to_string(k)+to_string(l)));
		}
	    }
	}
    }


    while(true){
	double n;
	cin >> n;
	if(n<0) break;
	int m = (int)(n);
	n -= (double)(m);
	if((m&(0xff00))==0){
	    bool flg = false;
	    REP(i,num.size()){
		if(n == num[i].first) {
		    flg = true;
		    stack<int> ans;
		    while(m>0){
			ans.push(m%2);
			m /= 2;
		    }
		    REP(i,8-ans.size()){
			cout << 0;
		    }
		    while(!ans.empty()){
			cout << ans.top();
			ans.pop();
		    }
		    cout << "." + num[i].second << endl;
		    break;
		}
	    }
	    if(!flg) cout << "NA" << endl;
	}else{
	    cout <<"NA"<<endl;
	}
    }
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	map<ll, string> ma, mb;
	REP(i, 1<<8) {
		string str = "";
		int sum = 0;
		
		REP(j, 8) {
			if (i >> j & 1) sum += 1<<j;
			str += '0' + (i >> j & 1);
		}
		
		reverse(ALL(str));
		ma[sum] = str;
	}
	
	int num[4] = {5000, 2500, 1250, 625};
	REP(i, 1<<4) {
		string str = "";
		int sum = 0;
		
		REP(j, 4) {
			if (i >> j & 1) sum += num[j];
			str += '0' + (i >> j & 1);
		}
		mb[sum] = str;
	}
	
	string str;
	while (cin >> str, str[0] != '-') {
		string A = str.substr(0, str.find('.'));
		string B = str.substr(str.find('.') + 1, str.size());
		while (B.size() < 4) B += '0';
		
		if (B.size() > 4) assert(false);
		
		ll a = atol(A.c_str()), b = atol(B.c_str());
		
		if (ma.find(a) == ma.end() || mb.find(b) == mb.end()) puts("NA");
		else cout << ma[a] << "." << mb[b] << 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){
		int na = n;
		double nb = n-(double)na;
		
		int flag = 0;
		
		if (na <= 255 && 0 <= na){
			if (nb >= 0.0625){
				flag = 1;
			}
		}
		
		REP(i,12){
			ans[i] = 0;
		}
		
		double base = 128;
		if (flag){
			REP(i,12){
				if (base <= n){
					ans[i] = 1;
					n -= base;
				}
				if (i == 11 && n){
					flag = 0;
				}
				base /= 2.0;
			}
		}
		
		if (flag){
			REP(i,12){
				printf("%d", ans[i]);
				if (i == 7){
					printf(".");
				}
			}
			puts("");
		}
		else {
			puts("NA");
		}
	}
	
	return 0;
}