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;
 
 
 
 
const int INF = 1000000;
const double EPS = 1e-9;
const int mod = 1e9 + 7;
 
 
string tobi(int n, int d){
    string ret(d, '0');
    int i = 0;
    while(n > 0){
        ret[i] += n % 2;
        n /= 2;
        i++;
        if(i >= d) return "f";
    }
    reverse(all(ret));
    return ret;
}
 
string tobi2(double n){
    string ret(4, '0');
    for(int i = 0; i < 4; i++){
        n *= 2;
        ret[i] += (int)n % 2;
        n -= ret[i] - '0';
    }
    if(n > EPS) return "f";
    return ret;
}
 
int main(){
    string s;
    while(cin>>s){
        if(s[0] == '-') break;
        string t, u = "0";
        if(s.find(".") == string::npos) t = s, u = "0";
        else {
            t = s.substr(0, s.find("."));
            u += s.substr(s.find("."));
        }
 
                 
        t = tobi(atoi(t.c_str()), 8);
        u = tobi2(atof(u.c_str()));
 
 
        if(t == "f" || u == "f") {
            cout<<"NA"<<endl;
            continue;
        }
 
        cout<<t<<"."<<u<<endl;
    }
 
}

C++: #include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	double a,z;
	int s,d[9],f[5],g,h,i,j,x;
	while(1){
		scanf("%lf",&a);
		s=a;
		if(s==-1) break;
		z=a-s;
		x=0;
		for(i=0;i<4;i++){
			f[i]=0;
			if(1<=z*2) f[i]=1;
			z=z*2;
			if(f[i]==1) z-=1;
			if(z==0) x=1;
		}
		g=256;
		h=0;
		if(x==0) printf("NA\n");
		else{
			for(i=7;i>=0;i--){
				d[i]=0;
				if(g<s&&h==0) g/=2;
				else{
					h=1;
					if(s%2==1) d[i]=1;
					s/=2;
				}
			}
		for(i=0;i<8;i++) printf("%d",d[i]);
		printf(".");
		for(i=0;i<4;i++) printf("%d",f[i]);
		printf("\n");
		}
	}
	return 0;
}

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

int main(){
	double d;
	while( cin >> d, d>=0.0 ){
		int n = (int)(d*16.0);
		if( (double)n != d*16.0 || (int)d > 256 ){
			cout << "NA" << endl;
			continue;
		}
		for( int i=11; i>=4; i-- ){
			cout << (n&(1<<i) ? '1':'0');
		}
		cout << '.';
		for( int i=3; i>=0; i-- ){
			cout << (n&(1<<i) ? '1':'0');
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
	double n;
	int nn,a[12];
	while(1){
		cin >> n;
		if(n < 0.0) break;
		if(n > 256.0) {
			cout << "NA" << endl;
			continue;
		}
		nn = (int)round(n * 16.0);
		if(abs((double)nn - n * 16.0) > 0.00001) {
			cout << "NA" << endl;
			continue;
		}
		for(int i = 11;i >= 0;i--){
			a[i] = nn % 2;
			nn /= 2;
		}
		for(int i = 0;i < 12;i++){
			cout << a[i];
			if(i == 7) cout << ".";
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    double n;

    while (cin >> n, n != -1.0) {
        int up = (int)n;
        string u, l;
        
        n -= up;
        while (up != 0) {
            u += (up % 2) + '0';
            up /= 2;
        }
        if (u.size() > 8) {
            cout << "NA" << endl;
            continue;
        }
        while (u.size() < 8)
            u += '0';
        reverse(u.begin(), u.end());

        for (int i = 0; i < 5; i++) {
            n *= 2;
            if ((int)n == 1) {
                l += '1';

                if (n - (int)n == 0)
                    break;
                n -= (int)n;
            }
            else 
                l += '0';
        }

        if (l.size() > 4) {
            cout << "NA" << endl;
            continue;
        }
        while (l.size() < 4)
            l += '0';
        cout << u << '.' << l << endl;
    }

    return 0;
}

C++: #include <cstdio>
#include <cmath>
#include <string>

using namespace std;

const double EPS=1e-9;

int main()
{
	//for(char buf[1024];fgets(buf,1024,stdin),buf[0]!='-';){
	//	double x; sscanf(buf,"%lf",&x);
	for(double x;scanf("%lf",&x),x>=0;){
		x/=256;
		
		if(x>=1){
			puts("NA");
			continue;
		}
		string s(12,'0');
		for(int i=0;i<12;i++){
			x*=2;
			if(x>=1){
				s[i]++;
				x-=1;
			}
		}
		if(x!=0){
			puts("NA");
			continue;
		}
		
		for(int i=0;i<8;i++)
			putchar(s[i]);
		putchar('.');
		for(int i=0;i<4;i++)
			putchar(s[8+i]);
		putchar('\n');
	}
	return 0;
}

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

float ans=0;
int d[8] = {128, 64, 32, 16, 8, 4, 2, 1};
float f[4] = {0.5, 0.25, 0.125, 0.0625};
int output[12];
float input;
int tmp = 0;
int main(){
	while(1){
		tmp = 0;
		for(int i=0; i < 12; i++)output[i] = 0;

		cin >> input;
		if(input < 0) break;

		for(int i=0; i < 8; i++){
			if(d[i] <= input){
				output[i] = 1;
				input -= d[i];
				tmp = 1;
			}
		}
		for(int i=0; i < 4; i++){
			if(f[i] <= input){
				output[i+8] = 1;
				input -= f[i];
				tmp = 1;
			}
		}
		if(tmp = 1 && input == 0){
			for(int i=0; i < 8; i++){
				cout << output[i];
			}
			cout << '.';
			for(int i=8; i < 12; i++){
				cout << output[i];
			}
			cout << endl;
		}
		else cout << "NA" << endl;
	}
}

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

bool a[8],b[4];
bool ue(int n)
{
	int pos = 128;
	for(int i=0;i<8;i++){
		if(n/pos==1){
			a[i] = 1;
			n %= pos;
		}else{
			a[i] = 0;
		}
		pos/=2;
	}
	if(n==0)
		return true;
	else
		return false;
}

bool sita(double n)
{
	double pos = 0.5;
	for(int i=0;i<4;i++){
		if(n-pos >= 0){
			b[i] = 1;
			n -= pos;
		}else{
			b[i] = 0;
		}
		pos/=2;
	}
	if(n==0)
		return true;
	else
		return false;
}

int main()
{
	double n;
	while(cin >> n){
		if(n < 0)
			break;
		if(ue(static_cast<int>(n)) && sita(n-static_cast<int>(n))){
			for(int i=0;i<8;i++){
				cout << a[i];
			}
			cout << ".";
			for(int i=0;i<4;i++){
				cout << b[i];
			}
			cout << endl;
		}else{
			cout << "NA" << endl;
		}
	}
	return 0;
}

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

int main(){
    char ans[13];
    int sub,bit[8] = {128,64,32,16,8,4,2,1};
    double dbit[4] = {0.5,0.25,0.125,0.0625};
    double n,dec;
    while(1){
        cin >> n;
        sub = n;
        dec = n - sub;
        if(n < 0.0) break;
        for(int i=0;i<8;i++){
            if(bit[i] <= n){
                n -= bit[i];
                ans[i] = '1';
            }
            else ans[i] = '0';
        }
        if(n >= 1){
            cout << "NA" << endl;
            continue;
        }
        ans[8] = '.';
        for(int i=0;i<4;i++){
            if(dec >= dbit[i]){
                dec -= dbit[i];
                ans[i+9] = '1';
            }
            else ans[i+9] = '0';
        }
        if(dec != 0.0){
            cout << "NA" << endl;
            continue;
        }
        cout << ans << endl;
    }
}