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++: /* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */

// #define int long long

/* cpp template {{{ */
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
using namespace std;

/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

string ftoBinary(double n)
{
  double b;
  b = n - (int)n;
  string s;
  bool ok = false;

  if (b == 0){
    ok = true;
    s = "0000";
  } else {
    REP(i, 4){
      b *= 2;
      s += (int)b + '0';
      if (b == 1.0){
        ok = true;
      }
      b -= (int)b;
      // print(s);
    }
  }

  if (ok){
    return (s);
  }
  return ("NA");
}

string itoBinary(double n)
{
  string s;
  int b = (int)n;
  bool ok = false;

  REP(i, 8){
    s += (b % 2) + '0';
    b /= 2;
    if (b == 0){
      ok = true;
    }
    // print(s);
  }
  if (ok){
    reverse(s.begin(), s.end());
    return (s);
  }
  return ("NA");
}

signed main()
{
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  
  double n;
  while (scanf("%lf", &n), n >= 0){
    string a = itoBinary(n);
    string b = ftoBinary(n);
    if (a != "NA" && b != "NA"){
      printf("%s.%s\n", a.c_str(), b.c_str());
    } else {
      printf("NA\n");
    }
  }

  return (0);
}

C++: #include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int main(){
  double a;
  while(1){
    int data[12];
    cin>>a;
    if(a<0)break;
    double u=128.0;
    for(int i=0;i<12;i++){
      if(a>=u){
        data[i]=1;
        a-=u;
      }else data[i]=0;
      u/=2;
    }
    if(a!=0){
      cout<<"NA"<<endl;
      continue;
    }
    for(int i=0;i<12;i++){
      if(i==8)cout<<'.';
      cout<<data[i];
    }
    cout<<endl;
  }
}

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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  double a;
  while(cin >> a && a >= 0) {
    double b = a - (int)a;
    string ans = "";
    rep(i, 0, 2) rep(j, 0, 2) rep(k, 0, 2) rep(l, 0, 2) {
      double c = i * 0.5 + j * 0.25 + k * 0.125 + l * 0.0625;
      if(c == b) {
        ans += (char)(i + 48);
        ans += (char)(j + 48);
        ans += (char)(k + 48);
        ans += (char)(l + 48);
      }
    }
    double d = a - b;

    if(ans == "" || (int)d > 255) {
      cout << "NA" << endl;
      continue;
    }
    string ni = "0";
    rep(i, 0, (int)d) {
      dep(j, ni.length(), 0) {
        if(ni[j] == '0') {
          ni[j] = '1';
          rep(k, j + 1, ni.length()) {
            ni[k] = '0';
          }
          break;
        }
        if(j == 0) {
          int nii = ni.length();
          ni = "1";
          rep(i, 0, nii) ni += "0";
        }
      }
    }
    int kk = ni.length();
    rep(i, 0, 8 - kk) {
      ni = '0' + ni;
    }

    cout << ni + '.' + ans << endl;
  }
}

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

using namespace std;

int main(void){
  double in;
  while(cin>>in,in>=0){
    vector<int> ans(12,0);
    bool used = false;
    for(int i = 0 ; i < 8 ; i ++){
      if(in>=de[i]){
          ans[i] = 1;
          //cout<<in << " " << de[i] <<endl;
          in -= de[i];
          used = true;
         
      }
    }
    if((double)in - (int)in !=0)
    for(int i = 0 ; i < 4 ; 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 <vector>
#include <algorithm>
std::vector<int> dparttobinary(double n){
	std::vector<int> vec;
	while(n != 0){
		n *= 2;
		int ipart = (int)n;
		vec.push_back(ipart);
		n = n - (double)ipart;
	}
	std::reverse(vec.begin(), vec.end());
	return vec;
}

std::vector<int> iparttobinary(int n){
	std::vector<int> vec;
	while(n != 0){
		vec.push_back(n % 2);
		n /= 2;
	}
	std::reverse(vec.begin(), vec.end());
	return vec;
}

int main(){
	double n;
	while(std::cin >> n, n > 0){
		int ipart = (int)n;
		double dpart = n - (double)ipart;
		std::vector<int> dvec = dparttobinary(dpart),
			ivec = iparttobinary(ipart);
	
		if(dvec.size() <= 4 && ivec.size() <= 8){
			for(int i=8-ivec.size();i;i--)
				std::cout << "0";
			for(int i=0;i<ivec.size();i++)
				std::cout << ivec[i];
			std::cout << ".";
			for(int i=0;i<dvec.size();i++)
				std::cout << dvec[i];
			for(int i=4-dvec.size();i;i--)
				std::cout << "0";
			std::cout << "\n";
		}else{
			std::cout << "NA\n";
		}
	}
}

C++: #include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    double X;
    double nisin[12]={128,64,32,16,8,4,2,1,0.5,0.25,0.125,0.0625};
    while(cin>>X){
        X+=0.00000001;
        if(X<0)break;
        int check[12]={0};
        for(int i=0;i<12;i++){
            if(X>nisin[i]){
                //printf("[%d]",i);
                X-=nisin[i];
                check[i]=1;
            }
        }
        if(fabs(X)<0.000001){
            for(int i=0;i<12;i++){
                cout<<check[i];
                if(i==7)cout<<'.';
            }
            puts("");
        }
        else puts("NA");
    }
    return 0;
}