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 <cstdio>
#include <algorithm>
using namespace std;

int main(){
    double x;
    while(scanf("%lf",&x)){
        if(x<0) break;
        x *= 16;
        if(x > (1<<16)-1)
            printf("NA\n");
        else if(x == (int)x){
            char str[20];
            str[8] = '.';
            str[13] = '\0';
            int n = x;
            for(int i=0; i<12; i++)
                str[(i<4)?(12-i):(11-i)] = (n & (1<<i))?'1':'0';
            printf("%s\n",str);
        }
        else
            printf("NA\n");
    }

    return 0;
}

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

string r[16] = {
	"0000","5000","2500","7500",
	"1250","6250","1500","6500",
	"0625","5625","3125","8125",
	"1875","6875","4375","9375"
};

int s_to_i(string s){
	string s_;
	for(int i=0 ; i < s.size() ; i++ ){
		if( s[i] == '.' ) break;
		s_.push_back( s[i] );
	}
	int n = 0;
	for(int i=0 ; i < s_.size() ; i++ ){
		n *= 10;
		n += s_[i] - '0';
	}
	return n;
}

string s_to_f(string s){
	string s_;
	bool flag = false;
	for(int i=0 ; i < s.size() ; i++ ){
		if( flag ){
			s_.push_back( s[i] );
		}else if( s[i] == '.' ){
			flag = true;
		}
	}
	return s_;
}

string i_to_b(int n){
	string s = "00000000";
	if( n >= 256 ){
		return "NA";
	}
	for(int i=7 ; i >= 0 ; i-- ){
		if( n >= (1 << i) ){
			n -= (1 << i);
			s[7-i] = '1';
		}
	}
	return s;
}

string f_to_b(string f){
	while( f.size() < 4 ){
		f.push_back( '0' );
	}
	bool flag = false;
	string s;
	for(int i=0 ; i < 16 ; i++ ){
		if( f == r[i] ){
			flag = true;
			s = i_to_b( i );
		}
	}
	if( flag ){
		string b;
		for(int i = s.size()-1 ; i >= 4 ; i-- ){
			b.push_back( s[i] );
		}
		return b;
	}
	return "NA";
}

int main(){
	string s;
	while( cin >> s , s[0] != '-' ){
		int n = s_to_i( s );
		string f = s_to_f( s );
		string a = i_to_b( n );
		string b = f_to_b( f );
		if( a != "NA" && b != "NA" ){
			cout << a << "." << b << endl;
		}else{
			cout << "NA" << endl;
		}
	}
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); 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()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  int n,m;
  while(scanf("%d.%d",&n,&m), n >= 0){
    string ans;

    if( n > 255 ) ans = "NA";
    else{
      REP(i,8){
	if(n & (1 << i))
	  ans = "1" + ans;
	else
	  ans = "0" + ans;
      }

      ans += ".";
      if(m != 0)
	while(m*10 < 10000) m *= 10;

      REP(i,4){
	m *= 2;
	if( m >= 10000 ){
	  ans = ans + "1";
	  m -= 10000;
	}else{
	  ans = ans + "0";
	}
      }
      if( m != 0 ) ans = "NA";

      cout << ans << endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
//#include <fstream>

using namespace std;

string dec2bin (int n )
{
	string res = "";
	int count = 0;

	while (n > 0 || count < 8){
		res += n % 2 + '0';
		n /= 2;
		++count;
	} // end while
	
	reverse (res.begin(), res.end() );

	return res;
}

string dec2bin_dec (double n )
{
	string res = "";
	double d = 0.5;
	int count = 0;

	while (n > 0.0 || count < 4){
		
		if (n >= d ){
			n -= d;
			res += '1';
		}else{
			res += '0';
		} // end if
		d /= 2.;
		++count;
	} // end while

	return res;
}
int main()
{
//	cut here before submit 
//	freopen ("testcase.binarydigit", "r", stdin );
	double n;

	while (cin >> n && n >= 0.0 ) {
		int    integer = (int)n;
		double decimal = n - (double)integer;
		string resi = dec2bin (integer);
		string resd = dec2bin_dec (decimal );
		
		if (resi.length() > 8 || resd.length() > 4){
			cout << "NA" << endl;
		}else{
			cout << resi << '.' << resd << endl;
		} // end if
	} // end loop
		
	return 0;
}

C++: #include<iostream>
#include<vector>
int de[8] = {128,62,32,16,8,4,2,1};
double dou[4] = {0.5,0.25,0.125,0.0625};

int main(void){
  while(cin>>in,in){
    vector<int> ans(12,0);
    bool used = false;
    for(int i = 0 ; i < 8 ; i ++){
      if(in>de[i]){
          ans[i] = 1;
          in -= de[i];
          used = true;
      }
    }
    for(int i = 0 ; i < 4 ; i ++){
      if(in>dou[i]){
        if(in>dou[i]){
          ans[i+8] = 1;
          in -= dou[i];
          used = true;
        }
      }
    }
    if(used && in == 0){
      for(int i = 0 ; i < 8 ; i ++)
        cout<<ans[i];
      cout<<".";
      for(int i = 8 ; i < 12 ; i ++)
        cout<<ans[i];
      cout<<endl;
    }else 
      cout<<"NA"<<endl;
    
    
  }
}

C++: #include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

double d;

int main()
{
	while(scanf("%lf",&d),d>=0)
	{
		if(d>=256)
		{
			puts("NA"); continue;
		}
		rep(i,7)d/=2;
		int a[12]={0};
		rep(i,12)
		{
			if(d>=1)a[i]=1,d-=1;
			d*=2;
		}
		if(d!=0)puts("NA");
		else
		{
			rep(i,8)printf("%d",a[i]);
			putchar('.');
			rep(i,4)printf("%d",a[i+8]);
			puts("");
		}
	}
	return 0;
}

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

using namespace std;

string StrInput;


void convertToBinary() {
	double num;
	stringstream ss;
	string result;

	ss << StrInput;
	ss >> num;
	//cout << num << endl;
	result = "";
	for (double i = (1 << 7); i > 0.03125; i /= 2.0) {
		result += (int)(num / i) + '0';
		num -= (int)(num / i) * i;
		if (i == 1) {
			result += '.';
		}
		//cout << "result:" << result << endl;
	}

	if (num == 0) {
		cout << result << endl;
	}
	else {
		cout << "NA" << endl;
	}
}

int main() {
	
	while (cin >> StrInput, StrInput[0] != '-') {
		convertToBinary();
	}

	return 0;
}