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<stdio.h>
int main(void)
{
	int i,a[]={2048,1024,512,256,128,64,32,16,8,4.2,1},x[12];
	double n,s;
	while(1){
		scanf("%lf",&n);
		if(n<0)break;
		n=n*16;
//		printf("%f\n",n);
		if(n-(int)n>0){
			printf("NA\n");
		}
		else{
			for(i=0;i<12;i++){
				if(n-a[i]>=0){
					x[i]=1;
					n-=a[i];
				}
				else{
					x[i]=0;
				}
			}
			for(i=0;i<12;i++){
				if(i==8){
					printf(".");
				}
				printf("%d",x[i]);
			}
			printf("\n");
		}
	}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
 
 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
 
 
string tobi(int n, int d){
    string ret(d, '0');
    int i = 0;
    while(n > 0){
        ret[i] += n % 2;
        n /= 2;
        i++;
        if(i >= d) return "f";
    }
    reverse(all(ret));
    return ret;
}
 
string tobi2(double n){
    string ret(4, '0');
    for(int i = 0; i < 4; i++){
        n *= 2;
        ret[i] += (int)n % 2;
        n -= ret[i] - '0';
    }
    if(n > EPS) return "f";
    return ret;
}
 
int main(){
    string s;
    while(cin>>s){
        if(s[0] == '-') break;
        string t, u = "0";
        if(s.find(".") == string::npos) t = s, u = "0";
        else {
            t = s.substr(0, s.find("."));
            u += s.substr(s.find("."));
        }
 
                 
        t = tobi(atoi(t.c_str()), 8);
        u = tobi2(atof(u.c_str()));
 
 
        if(t == "f" || u == "f") {
            cout<<"NA"<<endl;
            continue;
        }
 
        cout<<t<<"."<<u<<endl;
    }
 
}

C++: #include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    double n;
    while(cin>>n){
        if(n<0)break;
        int ans[8]={};
        int ans_[4]={};
        for(int i=7;i>=0;i--){
            if(n>=(1<<i)){
                ans[i]=1;
                n-=(1<<i);
            }
            else ans[i]=0;
        }
        for(int i=1;i<=4;i++){
            if(n>=(double)1/(1<<i)){
                ans_[i-1]=1;

                n-=(double)1/(1<<i);
            }
            else ans_[i-1]=0;
        }
        if(n==0){
            for(int i=7;i>=0;i--){
                cout<<ans[i];
            }
            cout<<".";
            rep(i,4){
                cout<<ans_[i];
            }
            cout<<endl;
        }
        else{
            cout<<"NA"<<endl;
        }
        
    }
    
}

C++: #include<cstdio>
#include<cmath>
#include<string>
using namespace std;

void reverse(string &str){
	unsigned len = str.length();
	char t;
	for(unsigned i = 0;i < len / 2;i++){
		t = str[i];
		str[i] = str[len - i - 1];
		str[len - i - 1] = t;
	}
}

string int2bin(int n){
	string ret;
	while(n){
		ret += '0' + (n % 2);
		n /= 2;
	}
	reverse(ret);
	return ret;
}

string double2bin(double r){
	string ret;
	for(int i = 0;i < 5;i++){
		r *= 2.0;
		if(r >= 1.0){
			ret += '1';
			r -= 1.0;
		}
		else ret += '0';
		if(r == 0.0) break;
	}
	for(int i = ret.length();i < 4;i++){
		ret += '0';
	}
	return ret;
}

int main(){
	while(1){
		int n;
		double r;
		scanf("%lf", &r);
		n = floor(r);
		r -= floor(r);
		if(n < 0) break;
		string ansn = int2bin(n), ansr = double2bin(r);
		if(ansn.length() > 8 || ansr.length() > 4) printf("NA\n");
		else printf("%08s.%04s\n", ansn.c_str(), ansr.c_str());
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  double n;
  string s="";
  while(1){
    cin >> n;
    if(n<0){
      break;
    }
    if(n>=128){
      n-=128;
      s+="1";
    }
    else{
      s+="0";
    }
    if(n>=64){
      n-=64;
      s+="1";
    }
    else{
      s+="0";
    }
    if(n>=32){
      n-=32;
      s+="1";
    }
    else{
      s+="0";
    }
    if(n>=16){
      n-=16;
      s+="1";
    }
    else{
      s+="0";
    }
    if(n>=8){
      n-=8;
      s+="1";
    }
    else{
      s+="0";
    }
    if(n>=4){
      n-=4;
      s+="1";
    }
    else{
      s+="0";
    }
    if(n>=2){
      n-=2;
      s+="1";
    }
    else{
      s+="0";
    }
    if(n>=1){
      n-=1;
      s+="1";
    }
    else{
      s+="0";
    }

    s+=".";

    if(n>=0.5){
      n-=0.5;
      s+="1";
    }
    else{
      s+="0";
    }
    if(n>=0.25){
      n-=0.25;
      s+="1";
    }
    else{
      s+="0";
    }
    if(n>=0.125){
      n-=0.125;
      s+="1";
    }
    else{
      s+="0";
    }
    if(n>=0.0625){
      n-=0.0625;
      s+="1";
    }
    else{
      s+="0";
    }


    if(n==0){
      cout << s << endl;
    }
    else{
      cout << "NA" << endl;
    }

    s="";
  }
}

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

#define EPS (1e-8)
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EQ(a,b) (abs(a-b)<EPS)
#define pb push_back

double n;

string i2s(int i) {
  stringstream ss;
  ss<<i;
  return ss.str();
}

void solve() {
  int real; double imag = n;
  real = (int)imag;
  imag -= (double)real;
  string re, im;
  
  // real
  while (1) {
    if (real / 2 == 0) {
      re.insert(0, "1");
      break;
    }
    if (real % 2) {
      re.insert(0, "1");
    } else {
      re.insert(0, "0");
    }
    real /= 2;
  }
  
  if (re.size() > 8) {
    cout<<"NA"<<endl; return;
  }
  
  // imag
  rep (i,4) {
    imag *= 2;
    im += i2s((int)imag);
    if (imag >= 1) imag -= 1;
  }
  //cout<<imag<<endl;
  if (!EQ(imag, 0)) {
    cout<<"NA"<<endl; return;
  }
  
  while (im.size()!=4) im+="0";
  while (re.size()!=8) re.insert(0,"0");
  cout<<re<<"."<<im<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    if (n < 0) break;
    solve();
  }
  return 0;
}