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<bits/stdc++.h>
using namespace std;
int main(){
  int n,j;
  double qq;
  scanf("%lf",&qq);
  n=(int)qq;
  j=(int)(10000*qq)-10000*n;
  //cout<<n<<' '<<j<<endl;
  while(n>=0){
    int nn=n;
    int ji[8]={},kyo[4]={},a=0;
    for(int i=0;i<8;i++){
      if(nn%2!=0){
	ji[i]=1;
      }else{
	ji[i]=0;
      }
      nn=nn/2;
      // cout<<nn<<endl;
    }
    if(nn){
      a=1;
    }else if(j<10000){
      while(j<1000&&j!=0){
	j*=10;
      }
      int c=5000;
      for(int i=0;i<4;i++){
	//cout<<j<<endl;
	if((j-c)>=0){
	  kyo[i]=1;
	  j-=c;
	}else{
	  kyo[i]=0;
	}
	c/=2;
	//cout<<c<<endl;
      }
    }
    if(j){
      a=1;
    }
    if(a==0){
      for(int i=7;i>=0;i--){
	cout<<ji[i];
      }
      cout<<'.';
      for(int i=0;i<4;i++){
	cout<<kyo[i];
      }
      cout<<endl;
    }else{
      cout<<"NA"<<endl;
    }
    scanf("%lf",&qq);
    n=(int)qq;
    j=(int)(1000*qq)-1000*n;
  }
  return 0;
}

C++: #include<stdio.h>
int main()
{
	double n,p,a[]={.5,.25,.125,.0625};
	while(scanf("%lf",&n),n>=0)
	{
		int s=n,c[4]={0},i;
		p=n-s;
		for(i=0;i<4;++i)if(p>=a[i])p-=a[i],c[i]=1;
		if(p||s>255)puts("NA");
		else
		{
			for(i=128;i;i/=2)putchar(s&i?'1':'0');
			putchar('.');
			for(i=0;i<4;++i)putchar(c[i]?'1':'0');
			puts("");
		}
	}
	return 0;
}

C++: #include<vector>
#include<map>
#include<climits>
#include<set>
#include<queue>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<string>
#include<bitset>
#include<cstring>
#include<list>
using namespace std;
typedef vector<int>VI;
typedef vector<VI>VVI;
typedef vector<string>VS;
typedef pair<int,int>PII;
typedef long long LL;
typedef pair<LL,LL>PLL;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define PB push_back
#define EACH(i,c) for(typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define F first
#define S second

int main(){
    double x;
    while(cin>>x,x>=0){
        double d=1<<7;
        string ans="";
        REP(i,8){
            if(x>=d){
                x-=d;
                ans+="1";
            }
            else ans+="0";

            d/=2;
        }
        ans+=".";
        REP(i,4){
            if(x>=d){
                x-=d;
                ans+="1";
            }
            else ans+="0";
            d/=2;
        }
        if(x==0)cout<<ans<<endl;
        else cout<<"NA"<<endl;
    }

    return 0;
}

C++: #include<stdio.h>
int main(void)
{
	double n;
	int s,x[20],i;
	while(1){
		scanf("%lf",&n);
		if(n<0) break;
		s=((int)16*n);
		if(n*16-((double)s)!=0){
			printf("NA\n");
			continue;
		}
		for(i=0;i<12;i++) x[i]=0;
		for(i=0;i<12;i++){
			if(s%2==1) x[i]=1;
			else x[i]=0;
			s/=2;
			// printf("%d\n",s);
		}
		// printf("%d\n",cnt);
		if(s==0){
			for(i=11;i>=4;i--) printf("%d",x[i]);
			printf(".");
			for(i=3;i>=0;i--) printf("%d",x[i]);
			printf("\n");
		}
		else printf("NA\n");
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(void)
{
	double n;
	int dn;
	int b;
	vector<int> h(8);
	while(1){
		cin >> n;
		if(n==-1.0) break;
		if(256.0<=n||(n/0.0625-(int)(n/0.0625)!=0.0)){
			cout << "NA" << endl;
			continue;
		}
		dn=(int)n;
		for(int i=7;0<=i;i--){
			if(2^i<dn){
				h[i]=dn%2;
				dn/=2;
			}
		}
		for(int i=0;i<8;i++) cout << h[i];
		cout << '.';
		dn=(int)((n-(int)n)*10000);
		b=5000;
		for(int i=0;i<4;i++){
			if(dn>=b){
				cout << "1";
				dn-=b;
			}
			else cout << "0";
			b/=2;
		}
		cout << endl;
		h.clear();
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
    double n;
    while(cin>>n,n>=0){
        string str = "";
        int a = n;
        double b = n - (int)n;
        if(a > (1<<8)){
            cout<<"NA"<<endl;
            continue;
        }
        b*=2;
        for(int i = 0;i < 4;i++){
            int x = 0;
            if(b>=1)x = 1;
            str += (char)(x + '0');
            if(b>=1.0)b-=1.0;
            b*=2;
        }
        if(b>=1.0)b-=1.0;
        if(b>1e-8){
            cout<<"NA"<<endl;
            continue;
        }
        str = '.' + str;
        for(int i = 0;i < 8;i++){
            str = char(a%2 + '0') + str;
            a /= 2;
        }
        cout<<str<<endl;
    }
}

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

typedef long long ll;

#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

const int N = 8, M = 4;

int main()
{
    string s;
    while(cin >> s && (s[0] != '-')) {
        int n = 0, m = 0;
        for(int i = 0; i < s.find('.'); i++) 
            n = n * 10 + (s[i] - '0');
        
        for(int i = s.find('.') + 1; i < s.size(); i++) 
            m = m * 10 + (s[i]- '0');

        for(int i = 0; i < 8 - (s.size() - s.find('.') - 1); i++) 
            m *= 10;
        
        if(n < 1 << N) {
            int c,d,idx;
            string ns, ms;
            c = d = m;
            idx = 0;
            ms = "0000";
            for(int i = 0; i < 4; i++) {
                c *= 2;
                d = c / 100000000;
                ms[i] = '0' + d;
                if(c == 100000000)
                    break;
                else if(c > 100000000)
                    c -= 100000000;
            }
            if(c == 100000000) {
                c = d = n;
                idx = 7;
                ns = "00000000";
                while(c > 1) {
                    d = c % 2;
                    c /= 2;
                    ns[idx--] = d + '0';
                }
                ns[idx] = '0' + c;
                cout << ns << "." << ms <<  endl;
            } else {
                cout << "NA" << endl;
            }
        } else {
            cout << "NA" << endl;
        }
            
    }
    
}

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

int main()
{
	double n;
	while (cin >> n, n>=0.0)
	{
		int N = (int) n;
		double r = n - ((int) n);
		bool f = 0;
		bool bin[12];
		memset(bin, 0, sizeof(bin));

		if (N < 512)
		{
			for (int i=0; i<4; i++)
			{
				r *= 2.0;
				if (r >= 1)
				{
					r -= 1.0;
					bin[8+i] = 1;
				}
				else
					bin[8+i] = 0;

				if (r == 0.0)
				{
					f = 1;
					break;
				}
			}

			if (f)
			{
				int i=7;
				while (N)
				{
					bin[i--] = N%2;
					N /= 2;
				}

				for (int i=0; i<12; i++)
				{
					cout << ((bin[i]) ? 1 : 0);
					if (i==7) cout << '.';
				}
				cout << endl;
			}
		}

		if (!f) cout << "NA" << endl;
	}

	return 0;
}