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 <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;

typedef pair<int, pii> pip;
 
 
 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
 
vector<string> split(const string &s, char c = ' '){
	vector<string> ret;
	stringstream ss(s);
	string t;
	while(getline(ss,t,c)){
		ret.pb(t);
	}
	return ret;
}


int main(){
	string str;
	vector<string> v;
	bool f;
	while(cin>>str){
		if(str == "-1.0") break;
		f = true;
		v = split(str, '.');
		string s, t;
		int a = atoi(v[0].c_str()), b = atoi(v[1].c_str());
		//cout<<a<<" "<<b<<endl;
		if(b % 5 != 0) {
			cout<<"NA"<<endl;
			continue;
		}
		double e = atof(str.c_str()) - a;
		while(a > 0){
			s += (char)('0' + a % 2);
			a /= 2;
			if(s.size() > 8) {
				f = false;
				break;
			}
		}
		while(s.size() < 8) s += '0';
		reverse(all(s));

		double d = (double)1/2;
		while(e > 0.0){
			if(e >= d){
				t += '1';
				e -= d;
			} 
			else{
				t += '0';
			}
			d *= (double)1/2;
			if(t.size() > 4){
				f = false;
				break;
			}
		}
		while(t.size() < 4) t += '0';

		cout<<(f?(s+"."+t):"NA")<<endl;
	}
}

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

double to_f(const string &s) {
    istringstream is(s);
    double d;
    is >> d;
    return d;
}

string binary(int n, int p) {
    string s;
    int r = 1<<(p-1);
    while (r != 0) {
        if (n / r) {
            s.push_back('1');
        } else {
            s.push_back('0');
        }
        n %= r;
        r >>= 1;
    }
    return s;
}

int main() {
    string s;
    while (cin >> s) {
        if (s == "-1.0") break;
        int n; double d;
        n = (int)to_f(s);
        d = to_f(s) - n;
        cout << n << ' ' << d << endl;

        if (0 <= n && n < (1<<8) && d*16 == (int)(d*16)) {
            cout << binary(n, 8) << '.' << binary(d*16, 4) << endl;
        } else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

C++: #include<stdio.h>


#define limit ( 1 << 8 ) - 1




void seisuu( int over_zero )
{
	int len = 0 ;

	char out[] = { "00000000" } ;


	while( over_zero > 1 )
	{
		out[ len ] = ( over_zero % 2 ) + '0' ;

		over_zero /= 2 ;


		++len ;
	}


	out[ len++ ] = over_zero + '0' ;


	while( len-- )
	{
		printf( "%c" ,out[ len ] ) ;
	}


	return ;
}




bool shousuu( char *out ,double under_zero )
{
	int p = 0 ;


	while( p < 4 )
	{
		under_zero *= 2 ;

		out[ p++ ] = ( int )under_zero + '0' ;


		under_zero -= ( ( int )under_zero / 1 ) ;


		if( under_zero == 0 )
		{
			return true ;
		}
	}


	return false ;
}




int main()
{
	double num ;


	while( true )
	{
		char out[] = { "0000\n" } ;


		scanf( "%lf" ,&num ) ;


		if( num > limit || shousuu( out ,num - ( int )num ) == false )
		{
			puts( "NA" ) ;

			continue ;
		}


		if( num < 0 )
		{
			return 0 ;
		}



		seisuu( ( int )num ) ;


		printf( "." ) ;


		printf( out ) ;
	}
}

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

int main(){
  int i;
  double n,ans,j;
  while(1){
    cin >> n;
    if(n < 0) break; 
    j = 128;
    ans = 0.0;
    for(i=10000000;i>=1;i/=10){
      if(n - j >= 0.0){
	ans += (double)i;
	n -= j;
      }
      j /= 2.0;
    }
    j = 0.5;
    for(i=10;i<=10000;i*=10){
      if(n - j >= 0.0){
	ans += (double)1/i;
	n -= j;
      }
      j /= 2.0;
    }
    j = 10000000;
    if(n == 0.0){
      while(ans <= j){
	cout << "0";
	j /= 10;
      }
      printf("%.4f\n",ans);
    }
    else cout << "NA" << endl;
  }
  return 0;
}

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

int main(){
  
  while(1){
    
    double n;
    
    cin>>n;
    
    if(n==-1.0) break;
    
    double num=128.0;
    int cnt=0;
    int ans[12]={};
    
    while(n!=0 && cnt < 12){
      if(n-num >= 0){
	ans[cnt]=1;
	n-=num;
      }
      num/=2.0;
      cnt++;
    }
    
    if(cnt == 12 && n != 0) cout<<"NA"<<endl;
    else{
      for(int i=0;i<12;i++){
	if(i == 8) cout<<".";
	cout<<ans[i];
      }
      cout<<endl;
    }
    
  }
  
  return 0;
}

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

int main(){

  double n;

  while(1){
    cin >> n;
    if(n < 0) break;
    double m = 128,t = 0.5;
    string s;

    for(int i=0;i<8;i++){
      if(n >= m){
	n -= m;
	s += "1";
      }
      else s += "0";

      m /= 2;
    }

    s += ".";

    for(int i=0;i<4;i++){
      if(n >= t){
	n -= t;
	s += "1";
      }

      else s += "0";

      t /= 2;
    }

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

  }
}

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

double pow(int a){
  double res = 1;
  for (int i = 0; i < a; i++) {
    res /= 2;
  }
  return res;
}

int main(int argc, char *argv[]){
  double d;
  while (std::cin >> d) {
    if(d < 0)break;
    int digit = 7;
    string ans;
    for (int i = digit; i >= 0; i--) {
      if(d >= (1<<i)){
        ans = ans + '1';
        d -= (1<<i);
      }else{
        ans = ans + '0';
      }
    }
    ans = ans + ".";
    for (int i = 1; i <= 4; i++) {
      if(d >= pow(i)){
        ans = ans + '1';
        d -= pow(i);
      }else{
        ans = ans + '0';
      }      
    }
    if(d == 0)std::cout << ans << std::endl;
    else std::cout << "NA" << std::endl;
  }
  return 0;
}