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>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

int A = 0, B = 0, K = 0, T = 0, W = 0, N = 0, H = 0;
int n = 0;
double L = 0;
double S = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;

string C;
string sA, strB;
vector<vector<char>> map;
vector<double> num;
vector<string> str;

int sum = 0;


double tempd = 0.0;



void input() {
	while (true) {
		CI tempd;
		if (tempd < 0.0) {
			break;
		}
		num.push_back(tempd);
	}

	return;
}


int main(void) {
	double deci;
	int numd;
	vector<int> int_array;
	vector<int> deci_array;
	input();

	for (int i = 0; i < num.size(); i++) {
		numd = num[i];
		deci = num[i] - (double)numd;
		
		while (true) {
			if (numd == 0) {
				break;
			}
			int_array.push_back(numd % 2);
			numd /= 2;
		}
		if (int_array.size() > 8) {
			CO "NA" E
			int_array.clear();
			int_array.shrink_to_fit();
			deci_array.clear();
			deci_array.shrink_to_fit();
			continue;
		}
		 
		bool flag = false;
		int nx = 0;
		while (true) {
			if (deci == (double)(int)deci) {
				break;
			}
			nx++;
			deci *= 2;
			deci_array.push_back((int)deci % 10);
		
		
			if (deci_array.size() > 4) {
				CO "NA" E
				int_array.clear();
				int_array.shrink_to_fit();
				deci_array.clear();
				deci_array.shrink_to_fit();
				flag = true;
				break;
			}
		}
		if (flag) {
			flag = false;
			continue;
		}
		

		for (int j = 0; j < 8 - int_array.size(); j++) {
			CO 0;
		}
		for (int j = int_array.size() - 1; j >= 0; j--) {
			CO int_array[j];
		}
		CO ".";
		for (int j = 0; j < deci_array.size(); j++) {
			CO deci_array[j];
		}
		for (int j = 0; j < 4 - nx; j++) {
			CO 0;
		}
		CO "\n";
		int_array.clear();
		int_array.shrink_to_fit();
		deci_array.clear();
		deci_array.shrink_to_fit();
	}


	return 0;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;


int main(void){
	string n;
	while(cin >> n){
		if(n[0]=='-') break;
		int i=0,cnt=0,flag=false;
		rep(j,n.size()){
			if(n[j]=='.'){
				cnt=0,flag=true;
			}else{
				i=10*i+n[j]-'0';
				cnt++;
			}
		}
		if(flag==false) cnt=0;
		bool ok=true;
		rep(j,cnt){
			if(i%5) ok=false;
			i/=5;
		}
		rep(j,4-cnt) i*=2;
		if(i>=4096) ok=false;
		if(ok){
			for(int j=11;j>=4;--j){
				cout << ((i&(1<<j))>0);
			}
			putchar('.');
			for(int j=3;j>=0;--j){
				cout << ((i&(1<<j))>0);
			}
			puts("");
		}else{
			puts("NA");
		}
	}
	return 0;
}

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

main(){
    double x;
    int a;
    double b;

    while(1){
	cin >> x;
	if ( x < 0 ) break;
	a = (int)x;
	b = x - a;
	vector<int> A, B;
	while(a){ A.push_back(a%2); a /= 2; }
	while(b >= 1.0) b /= 10;
	while(b){ 
	    b *= 2;
	    if ( b >= 1.0 ){ B.push_back(1); b -= 1; }
	    else B.push_back(0);
	    if ( B.size() > 4 ) break;
	}
	while( A.size() < 8 ) A.push_back(0);
	while( B.size() < 4 ) B.push_back(0);
	if ( A.size() > 8 || B.size() > 4 ) cout << "NA" << endl;
	else {
	    for ( int i = A.size()-1; i >= 0; i-- ) cout << A[i];
	    cout << ".";
	    for ( int i = 0; i < B.size(); i++ ) cout << B[i];
	    cout << endl;
	}
    }
    
}

C++: import java.util.*;

class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    
    while (true) {
      double n = sc.nextDouble();
      if (n == -1) break;
      
      int left = (int)n;
      String lhs = Integer.toString(left, 2);
      
      if (lhs.length() > 8) {
        System.out.println("NA");
        continue;
      }
      
      double right = n % 1;
      String rhs = "";
      //int rem = 4;
      
      HashSet<Double> hs = new HashSet<Double>();
      hs.add(right);
      while (true) {
        right *= 2;
        if (hs.contains(right)) break;
        hs.add(right);
        
        rhs += (int)right;
        right %= 1;
      }
      if (rhs.length() > 4) {
        System.out.println("NA");
        continue;
      }
      /*
      while (rem-- > 0 && right != 0) {
         right *= 2;
         rhs += (int)right;
         right %= 1;
      }
      
      if (right != 0) {
        System.out.println("NA");
        continue;
      }*/
      
      while (lhs.length() != 8) lhs = "0" + lhs;
      while (rhs.length() != 4) rhs += "0";
      
      System.out.println(lhs + "." + rhs);
    }
  }
}

C++: #include<bits/stdc++.h>
using namespace std;

int main()
{
  double n;
  char str_i[8];
  char str_d[4];
  int inte;
  double dou;
  double po;
  int flag;

  while(1){
    cin >> n;
    if(n < 0) break;

    flag = 0;

    //nを整数部と小数部に分解
    inte = (int)n;
    dou = n - (double)inte;

    //整数部を二進数変換
    if(inte >= 256){
      flag = 1;
    }else{
      for(int i = 0;i < 8;++i){
	if(inte % 2){
	  str_i[i] = '1';
	}else{
	  str_i[i] = '0';
	}
	inte /= 2;
      }
    }

    /*
    for(int i = 0;i < 8;++i){
      cout << str_i[7 - i];
    }
    cout << endl;
    */

    if(!flag){
      for(int i = 0;i < 4;++i){
	if(dou * 2 >= 1.0){
	  str_d[i] = '1';
	  dou = dou * 2.0 - 1.0;
	}
	else{
	  str_d[i] = '0';
	  dou *= 2.0;
	}
      }
      if(dou != 0) flag = 1;
    }

    /*
    for(int i = 0;i < 4;++i){
      cout << str_d[i];
    }
    cout << endl;
    */
    
    if(flag){
      cout << "NA" << endl;
    }else{
      for(int i = 0;i < 8;++i){
	cout << str_i[7 - i];
      }
      cout << '.';
      for(int i = 0;i < 4;++i){
	cout << str_d[i];
      }
      cout << endl;
    }

  }

  return 0;
}

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

string p(int n,int d){
	string r;
	for(int i = 0 ; i < d ; i++){
		r = ( string(1,n % 2 + '0') + r) ; n/=2;
	}
	return r;
}
int main(){
	double r;
	while(cin >> r && r >= 0.0){
		int n = r;
		bool f = true;
		int s = (r-n)*16;
		if((r-n)*16 != s) f = false;
		f &= s < 16;
		f &= n < 256;
		if(f)cout << p(n,8) << "." << p(s,4) << endl;
		else cout << "NA" << endl;
	}
}