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<algorithm>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
int main(){
	double n;

		//for(int i=0;i<ans.size();i++)cout<<ans[i]<<" ";cout<<endl;
	while(cin>>n){
	if(n<0)break;
	vector<bool>ans(0);
	queue< vector<bool> >bfs;
	bfs.push(ans);
	while(!bfs.empty()){
		vector<bool>tmp=bfs.front();
		bfs.pop();
		if(tmp.size()>12){
		cout<<"NA"<<endl;
		break;
		}
		double sum=0;
		for(int i=0;i<min(8,(int)tmp.size());i++)if(tmp[i])sum+=pow(2,7-i);
		for(int i=0;i<min(4,(int)tmp.size()-5);i++)if(tmp[8+i])sum+=pow(2,-1*(i+1));
		if(sum==n){
		int cnt=0;
		for(int i=0;i<tmp.size();i++){
		cout<<tmp[i];
		if(cnt==7)cout<<'.';
		cnt++;
		}
		for(int i=0;i<12-tmp.size();i++){
		cout<<'0';
		if(cnt==7)cout<<'.';
		cnt++;
		}
		cout<<endl;
		break;
		}
		tmp.push_back(0);
		bfs.push(tmp);
		tmp.erase(tmp.begin()+(tmp.size()-1));
		tmp.push_back(1);
		bfs.push(tmp);
	}
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;


string integer_to_bin(int n, int digits)
{
	string res;
	while (n)
	{
		res = (n & 1 ? '1' : '0') + res;
		n >>= 1;
	}
	return string(max(0, digits-(int)res.size()), '0') + res;
}
string fraction_to_bin(double n, int digits)
{
	string res;
	while (n > EPS)
	{
		n *= 2;
		if (n+EPS > 1)
		{
			n -= 1;
			res += '1';
		}
		else
			res += '0';
	}
	return res + string(max(0, digits-(int)res.size()), '0');
}
int main()
{
	double n;
	while (scanf("%lf", &n), n >= 0)
	{
		string integer = integer_to_bin((int)n, 8);
		string fraction = fraction_to_bin(n - (int)n, 4);
		if (integer.size() <= 8 && fraction.size() <= 4)
			printf("%s.%s\n", integer.c_str(), fraction.c_str());
		else
			puts("NA");
	}

	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("NG");
		}
	}
	return 0;
}

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

main(){
	
	double n ;
	while( cin >> n ){
		if( n < 0 ) break ;
		
		int a = n ;
		double b = n - a ;
		
		vector<int> A ;
		vector<int> B ;
		
		while( a ){
			A.push_back(a%2) ;
			a /= 2 ;
		}
		
		int cnt = 0 ;
		while( b ){
			if( cnt > 4 ) break ;
			int c = b*2 ;
			B.push_back(c) ;
			b = b*2 - c ;
			cnt++ ;
		}
		
		if( A.size() > 8 || B.size() > 4 ){
			cout << "NA" << endl ;
			continue ;
		}else {
			for( int i=A.size()-1 ; i<8 ; i++ ) A.push_back(0) ;
			for( int i=B.size()-1 ; i<4 ; i++ ) B.push_back(0) ;
		}
		int k=128 ;
		for( int i=7 ; i>=0 ; i-- ) cout << A[i] ;
		cout << "." ;
		for( int i=0 ; i<4 ; i++ ) cout << B[i] ;
		cout << endl ;
	}
	
}

C++: #include <cmath>
#include <iostream>

using namespace std;

int main()
{
	double D;

	while (true)
	{
		cin >> D;

		if (D < 0.0) { break; }

		if (D >= 256.0 || fmod(D * 16.0, 1.0) != 0.0)
		{
			cout << "NA" << endl;
		}
		else
		{
			for (int i = 7; i > -5; i--)
			{
				cout << (int)(D / pow(2, i)) % 2;

				if (i == 0)
				{
					cout << '.';
				}
			}

			cout << endl;
		}
	}

	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int m;
double n;
bool flag;
vector<int> t;
vector<int> u;
int main(){
  while(1){
    cin>>n;
    if(n==-1.0)break;
    t.clear();
    u.clear();
    flag=false;
    m=n;
    n-=m;
    for(int i=128;i>=1;i/=2){
      if(m<i){
	t.push_back(0);
      }else{
	m-=i;
	t.push_back(1);
      }
    }
    if(m!=0)flag=true;
    double j=0.5;
    for(int i=0;i<4;i++){
      if(n<j){
	u.push_back(0);
      }else{
	n-=j;
	u.push_back(1);
      }
      j*=0.5;
    }
    if(n!=0)flag=true;
    if(flag){
      cout<<"NA"<<endl;
    }else{
      for(int i=0;i<8;i++)cout<<t[i];
      cout<<'.';
      for(int i=0;i<4;i++)cout<<u[i];
      cout<<endl;
    }
  }
  return 0;
}