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 <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;


int main(){
    while(1){
        string input;
        cin >> input;
        if(input[0]=='-')break;

        int dot_i;
        for(int i=0;i<input.size();i++){
            if(input[i]=='.'){
                dot_i = i;
                break;
            }
        }

        int p=1, a=0, b=0;
        for(int i=dot_i-1;i>=0;i--){
            a += (input[i]-'0') * p;
            p *= 10;
        }
        p = 1000;
        for(int i=dot_i+1;i<input.size();i++){
            b += (input[i]-'0') * p;
            p /= 10;
        }

        string a_str = "00000000", b_str = "0000";
        for(int i=0;i<8&&a>0;i++){
            a_str[7-i] += a&1;
            a >>= 1;
        }
        p = 5000;
        for(int i=0;i<4;i++){
            b_str[i] += b / p;
            b %= p;
            p /= 2;
        }

        if (a>0||b>0){
            cout << "NA" << endl;
        }else{
            cout << a_str << "." << b_str << endl;
        }
    }

    return 0;
}

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

int main() {
	double n, over = 127, 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<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<iostream>
using namespace std;
int main(void)
{
	int i,j,k;
	double n,w,nn;
	int rin;
	int suu[8]={128,64,32,16,8,4,2,1};
	int suu2[4]={8,4,2,1};
	int sei[8],syo[4];
	char sei2[9],syo2[4];
	while(1) {
		cin >>n;
		if(n<0) break;
		for(i=0;i<8;i++) {
			if(n-suu[i]>=0) {
				sei2[i]='1';
				n=n-suu[i];
			}
			else {
				sei2[i]='0';
			}
		}
		sei2[i]='.';
		sei2[i+1]='\0';
		n=n*16;
		for(i=0;i<4;i++) {
			if(n-suu2[i]>=0) {
				syo2[i]='1';
				n=n-suu2[i];
			}
			else {
				syo2[i]='0';
			}
		}
		if(n==0){
			syo2[i]='\0';
			strcat(sei2,syo2);
			cout << sei2 <<endl;
		}
		else cout << "NA" <<endl;
	}
	exit(0);
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

typedef long long Int;

string int2str(Int src, int base) {
  string res;
  while(src != 0) {
    char c = src%base;
    if (c < 10) c += '0';
    else c += 'a'-10;
    res = string(1,c) + res;
    src /= base;
  }
  return res;
}

int main() {
  double a;
  while(cin>>a, a>=0) {
    int i = (int)a;
    if (i>=256) {
      cout << "NA" << endl;
      continue;
    }
    string s;
    REP(j,8) {
      s = string(1,'0'+i%2) + s;
      i /= 2;
    }
    double d = a-(int)a;
    string s1;
    REP(j,4) {
      d *= 2;
      if (d>=1) {
        s1 += "1";
        d -= 1;
      } else
        s1 += "0";
    }
    if (d == 0) {
      cout << s + "." + s1 << endl;
    } else
      cout << "NA" << endl;
  }
}

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

void NA();

int main(){
	double n,nd;
	int ni;
	int inte[8],dec[4];
	
	while (cin >> n,n > 0){
		//初期化
		for ( int i = 0; i < 8; i++ ){
			inte[i] = 0;
			if ( i < 4 )
				dec[i] = 0;
		}
		
		ni = (int) n;
		nd = n - (int)n;
		
		for ( int i = 0; i < 8; i++ ) {
			inte[i] = ni % 2;
			ni = ni / 2;
		}
		if ( ni > 1 ) {
			NA ();
			continue;
		}
		
		for ( int i = 0; i < 4; i++ ) {
			dec[i] = (int)(nd * 2);
			if ( !dec[i] )	nd = nd * 2;
			else	nd = nd * 2 - 1;
		}
		if ( nd ) {
			NA ();
			continue;
		}
		
		for ( int i = 7; i >= 0; i-- ) {
			cout << inte[i];
		}
		cout << ".";
		for ( int i = 0; i < 4; i++ ) {
			cout << dec[i];
		}
		cout << endl;
	}
	return 0;
}

void NA () {
	cout << "NA" << endl;
}

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;
	string sm;
	while(scanf("%d.", &n)){
		cin >> sm;
		while(1){
			if(sm.length() >= 4){
				break;
			}
			sm+="0";
		}
		int m = StrToInt(sm);
		if(n < 0)break;
		if(n > 511 || sm.length() > 4){
			cout << "NA" << endl;
			continue;
		}
		bitset<8> re(n);

		int d[4] = {0};
		double d_ans = 0.5;
		rep(i, 4){
			d[i] = (int)(d_ans*10000);
			d_ans /= 2.0;
		}
		string s;
		rep(i, 4){
			if(m >= d[i]){
				m -= d[i];
				s+="1";
			}else{
				s+="0";
			}
		}
		if(m != 0){
			cout << "NA" << endl;
			continue;
		}

		cout << re << "." << s << 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()
{
	for(double a;cin>>a,a>=0;){
		int n=(int)(a*16);
		if(n>(1<<12) || n!=a*16)	cout<<"NA"<<endl;
		else{
			for(int i=11;i>=0;i--){
				if(i==3)	cout<<'.';
				cout<<(bool)(n&(1<<i));
			}
			cout<<endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
const double eps = 1e-9;

string to_bit(double n) {
    string s = "";
    for (int i=8; i>=-4; --i) {
        double d = pow(2, i);
        if (d < n + eps) {
            n -= d;
            s += "1";
        } else {
            s += "0";
        }
        if (i == 0) s += ".";
    }
    return s;
}

int main() {
    double n;
    while (cin >> n, 0 <= n) {
        if (abs(n*16 - round(n*16)) < eps && n < 512 + eps) {
            cout << to_bit(n) << endl;
        } else {
            cout << "NA" << endl;
        }
    }
    return 0;
}