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 <cstdio>
#include <algorithm>
using namespace std;
int main() {
	double n;
	while(scanf("%lf",&n),n>=0) {
		double x=(1<<7);
		char d[15];
		int idx=0;
		for(int i=7;i>=-4;i--) {
			if(i==-1) d[idx++]='.';
			if(n>=x) {
				n-=x;
				d[idx++]='1';
			}else {
				d[idx++]='0';
			}
			x/=2.0;
		}
		d[idx]='\0';
		if(n!=0) printf("NA\n"); else printf("%s\n",d);
	}
}

C++: 
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	double num,flt;
	while (cin >> num, num > 0) {
		string ans="";
		int F[5] = {0}, I[10] = { 0 };
		int i = 0, j = 7;
		int n = (int)num;
		flt = num - n;

		if (n > 255) ans = "NA";
		else {
			rep(i, 4) {
				flt *= 2;
				F[i] = flt >= 1.0 ? 1 : 0;

				if (flt == 1.0)break;
				else if (flt > 1.0)
					flt = flt-1.0;
			}

			if (flt != 1.0)ans = "NA";
			if (flt == 0)ans = "";

			if (ans == "NA")cout << ans << endl;
			else {
				while (1) {
					I[j--] = n % 2;
					n /= 2;
					if (n == 0)break;
				}
				rep(i, 8)cout << I[i];
				cout << ".";
				rep(i, 4)cout << F[i];
				cout << endl;
			}
		}
	}
	return	0;
}

C++: #include <cstdio>
#include <iostream>
#include <iomanip>
#include <string> 
#include <vector> 
using namespace std;
  
int main(){
    /*??£???????????????????????????
            int a[2];
            cin >> a[1] >> a[2];
            cout << "[+] " << a[1] + a[2] << endl;
            cout << "[-] " << a[1] - a[2] << endl;
            cout << "[*] " << a[1] * a[2] << endl;
            cout << "[/] " << a[1] / a[2] << endl;
    */

    double a,c,i;
    int b,e;
    while(cin >> a){
        if(a < 0){break;}
        string ans[2] = {"",""},aa;
        b = a;
        c  = a - b;
        int co[2] = {0,0},check = 0;
        while(b > 0){
            if(b % 2 == 1){
                ans[0] = "1" + ans[0];
            }else{
                ans[0] = "0" + ans[0];
            }
            b = b / 2;
            co[0]++;
            //cout << ans[0] << " " << co[0] <<  endl; 
            if(co[0] >= 8){check = 1;break;}
        }
        //cout << co[0] << endl;
        for(int i = co[0];7 >= i;i++){
            ans[0] = "0" + ans[0];
        }
        while(c != 0){
            c = c * 2;
            
            if(c >= 1){
                ans[1] = ans[1] + "1";
                co[1]++;
                if(co[1] >= 4){check = 1;break;}
                if(c == 1){break;}
            }else{
                ans[1] = ans[1] + "0";
                co[1]++;
                if(co[1] >= 4){check = 1;break;}
            }
            
        }
        //cout << co[1] << endl;
        for(int i = co[1];3 >= i;i++){
            ans[1] = ans[1] + "0";
        }        
        if(check == 1){
            cout << "NA" << endl;
        }else{
        cout << ans[0] << "." << ans[1] << endl;
    }
    }
}

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[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<stdio.h>



char hex[ 256 ][ 5 ] ;



int main()
{
	char p = '0' ;
	sprintf( hex[ p++ ] ,"0000" ) ;
	sprintf( hex[ p++ ] ,"0001" ) ;
	sprintf( hex[ p++ ] ,"0010" ) ;
	sprintf( hex[ p++ ] ,"0011" ) ;
	sprintf( hex[ p++ ] ,"0100" ) ;
	sprintf( hex[ p++ ] ,"0101" ) ;
	sprintf( hex[ p++ ] ,"0110" ) ;
	sprintf( hex[ p++ ] ,"0111" ) ;
	sprintf( hex[ p++ ] ,"1000" ) ;
	sprintf( hex[ p   ] ,"1001" ) ;	

	p = 'a' ;
	sprintf( hex[ p++ ] ,"1010" ) ;
	sprintf( hex[ p++ ] ,"1011" ) ;
	sprintf( hex[ p++ ] ,"1100" ) ;
	sprintf( hex[ p++ ] ,"1101" ) ;
	sprintf( hex[ p++ ] ,"1110" ) ;
	sprintf( hex[ p   ] ,"1111" ) ;


	double n ;

	while( 1 )
	{
		scanf( "%lf" ,&n ) ;

		if( n < 0 )
		{
			return 0 ;
		}


		int seisuu = ( int )n ;


		if( ( double )( n * 16 - ( int )( n * 16 ) ) > 0 )
		{
			puts( "NA" ) ;
		}

		else
		{
			int str_p = 0 ;

			int shousuu = ( int )( ( n * 16 ) - ( seisuu * 16 ) ) ;


			char str[ 20 ] ;
			sprintf( str ,"%x%x" ,seisuu ,shousuu ) ;


			if( str[ 2 ] == '\0' )
			{
				printf( "0000" ) ;
			}

			else
			{
				printf( "%s" ,hex[ str[ 0 ] ] ) ;

				++str_p ;
			}

			printf( "%s.%s\n" ,hex[ str[ str_p ] ] ,hex[ str[ str_p + 1 ] ] ) ;
		}
	}
}