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<stack>
#include<queue>
using namespace std;
int main(){
	double n,j;
	int i,count;
	bool flag = true;
	stack<int> s;
	queue<int> q;
	while(cin >> n){
		if(n < 0) return 0;
		count = 0;
		i = n; j = n-i;
		while(i > 3 && count <= 8){
			s.push(i%2);
			i/=2;
			count++;
		}
		if(count > 8)
			flag = false;
		s.push(i%2);
		s.push(i/2);
		count += 2;
		for(int x=count; x<8; x++)
			s.push(0);
		count=0;
		
		while( j != 1.0  && count <= 4){
			q.push(j*2);
			j *= 2;
			if(j > 1)
				j -= 1;
			count++;
		}
		if(count > 4)
			flag=false;
		for(int x=count; x<4; x++)
			q.push(0);

		if(flag == true){
			int size=s.size(), size1=q.size();
			for(int x=0; x<size; x++){
				cout << s.top();
				s.pop();
			}
			cout << '.';
			for(int x=0; x<size1; x++){
				cout << q.front();
				q.pop();
			}
		}
		else{
			cout << "NA";
		}
		
		cout << endl;
	}

	return 0;
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
#define rep(i,j) for(int i=0;i<j;i++)
int main(){
	double num;
	while(scanf("%lf",&num),num!=-1.0){
		num *= 16;
		int integer = (int)num;
		if(num != integer)puts("NA");
		else{
			char ans[32]={0};
			int cnt = 0;
			while(cnt < 13){
				ans[cnt] = (integer%2)+48;
				integer /= 2;
				if(cnt == 3){
					ans[++cnt] = '.';
				}
				++cnt;
			}
			reverse(ans,ans+13);
			rep(i,13)printf("%c",ans[i]);
			puts("");
		}
	}
    return 0;
}

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

int main(){

	float n;
	float temp_1[8] = { 128.0, 64.0, 32.0, 16.0, 8.0, 4.0, 2.0, 1.0 };
	float temp_2[4] = { 0.5, 0.25, 0.125, 0.0625 };

	while (cin >> n && n >= 0.0){

		int temp_a[8], temp_b[4];

		for (int i = 0; i < 8; i++){

			if (n >= temp_1[i]){

				temp_a[i] = 1;
				n -= temp_1[i];
			}
			else temp_a[i] = 0;
		}

		if (n >= 1.0){

			cout << "NA" << endl;
			continue;
		}

		for (int i = 0; i < 4; i++){

			if (n >= temp_2[i]){

				temp_b[i] = 1;
				n -= temp_2[i];
			}
			else temp_b[i] = 0;
		}

		if (n != 0.0){

			cout << "NA" << endl;
			continue;
		}

		for (int i = 0; i < 8; i++)
			cout << temp_a[i];
		cout << '.';
		for (int i = 0; i < 4; i++)
			cout << temp_b[i];

		cout << endl;
	}
}

C++: #include <cstdio>
#include <cstring>

#define rep(i, j) FOR(i, 0, j)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define W(i, j) ((i) ? (j) : 0)

using namespace std;

int main(){
  double a;
  while(scanf("%lf", &a) && a > 0){
    bool f = false;
    rep(i, 2) rep(j, 2) rep(k, 2) rep(l, 2) rep(m, 2) rep(n, 2) rep(o, 2) rep(p, 2) rep(q, 2) rep(r, 2) rep(s, 2) rep(t, 2)
      if(W(i,128)+W(j,64)+W(k,32)+W(l,16)+W(m,8)+W(n,4)+W(o,2)+W(p,1)+W(q,0.5)+W(r,0.25)+W(s,0.125)+W(t,0.0625) == a){
	printf("%d%d%d%d%d%d%d%d.%d%d%d%d\n",i,j,k,l,m,n,o,p,q,r,s,t);
	f = true;
      }
    if(!f) puts("NA");
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
  double in;
  while(cin>>in,in!=-1){
    if(in>256){cout<<"NA"<<endl;continue;}
    cout<<(64<=in&&in<128?1:0);
    if(64<=in)in-=64;
    cout<<(32<=in&&in<64?1:0);
    if(32<=in)in-=32;
    cout<<(16<=in&&in<32?1:0);
    if(16<=in)in-=16;
    cout<<(8<=in&&in<16?1:0);
    if(8<=in)in-=8;
    cout<<(4<=in&&in<8?1:0);
    if(4<=in)in-=4;
    cout<<(2<=in&&in<4?1:0);
    if(2<=in)in-=2;
    cout<<(1<=in&&in<2?1:0);
    if(1<=in)in-=1;
    cout<<".";
    cout<<(0.5<=in&&in<1?1:0);
    if(0.5<=in)in-=0.5;
    cout<<(0.25<=in&&in<0.5?1:0);
    if(0.25<=in)in-=0.25;
    cout<<(0.125<=in&&in<0.25?1:0);
    if(0.125<in)in-=0.125;
    cout<<(0.0625<=in&&in<0.125?1:0);
    if(0.0625<in)in-=0.0625;
    cout<<endl;
  }
}

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

using namespace std;

bool func();

int main()
{
	while(func()){};
	
	return false;
}

bool func()
{
	while(true)
	{
		double n = 0.0;

		cin >> n;

		if(n < 0)
		{
			return false;
		}

		double tmpi = 0;
		double d = 0; // 整数部格納
		double doubl_e = modf(n, &d); // 小数部格納
		int in_t = d;

		for(int i = 0; true; i++)
		{
			if(i > 8)
			{
				cout << "NA" << endl;
				return true;
			}

			tmpi += (in_t % 2) * pow(10, (double)i);
		
			in_t /= 2;


			if(in_t == 0)
			{
				break;
			}
		}

		int spi = 0;

		for(spi = 1; true; spi++)
		{
			if(spi >= 5)
			{
				cout << "NA" << endl;
				return true;
			}

			doubl_e *= 2;

			if(doubl_e >= 1)
			{
				doubl_e -= 1;
				tmpi += 1 * pow(10, (double)-spi);
			}

			if(doubl_e == 0)
			{
				break;
			}
		}

		bool flag = true;

		for(unsigned long int i = 10000000; true; i /= 10)
		{
			if(flag && tmpi == 0)
			{
				flag = false;
				i /= 10; 
			}

			if(tmpi >= i)
			{
				break;
			}

			cout << '0';
		}

		printf("%.4lf\n",  tmpi);

	}
}

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

unsigned numLen(int n){
	char buf[100];
	return sprintf(buf, "%d", n);
}

int pow(int n, int a){
	int ret = 1;
	for(int i = 0;i < a;i++) ret *= n;
	return ret;
}

void reverse(string &str){
	unsigned len = str.length();
	char t;
	for(unsigned i = 0;i < len / 2;i++){
		t = str[i];
		str[i] = str[len - i - 1];
		str[len - i - 1] = t;
	}
}

string int2bin(int n){
	string ret;
	while(n){
		ret += '0' + (n % 2);
		n /= 2;
	}
	reverse(ret);
	return ret;
}

string double2bin(int r){
	unsigned d = numLen(r);
	string ret;
	for(int i = 0;i < 5;i++){
		r *= 2;
		if(numLen(r) > d){
			ret += '1';
			r -= pow(10, d);
		}
		else{
			ret += '0';
		}
		if(r == 0) break;
	}
	for(int i = ret.length();i < 4;i++) ret += '0';
	return ret;
}

int main(){
	while(1){
		int n, r;
		scanf("%d.%d", &n, &r);
		if(n < 0) break;
		string ansN = int2bin(n), ansR = double2bin(r);
		if(ansN.length() > 8 || ansR.length() > 4) printf("NA\n");
		else{
			cout.width(8);
			cout.fill('0');
			cout << ansN;
			cout << '.';
			cout.width(4);
			cout.fill('0');
			cout << ansR;
			cout << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;


int main(){
    while(1){
        double n;
        scanf("%lf",&n);
        if(n<0)break;
        int a = (int)(n * 16);
        if(a>=(1<<12) || a!=(n*16)){
            cout << "NA" << endl;
        }else{
            for(int i=11;i>=0;i--){
                if(i==3) cout << ".";
                cout << ((a>>i)&1);
            }
            cout << endl;
        }
    }

    return 0;
}

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

int main()
{
	while (true){
		double n;
		cin >> n;
		if (n < 0) break;
		bool j[12];
		memset(j, false, sizeof j);

		for (int i = 0; i < 12; i++){
			if (n >= (double)128 / (1 << i)){
				j[i] = true;
				n -= (double)128 / (1 << i);
			}
		}
		if (!n){
			for (int i = 0; i < 12; i++){
				if (i == 8) cout << ".";
				cout << j[i];
			}
			cout << endl;
		}
		else{
			cout << "NA" << endl;
			while (true){
				double n2;
				cin >> n2;
				if (n2 < 0) return 0;
				cout << "NA" << endl;
			}
		}
	}
	return 0;
}