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

#include <algorithm>

#include <sstream>

#include <string>

#include <cmath>

using namespace std;



template <typename T> class SegTree

{

public:

	int n;

	T T_max;

	vector<T> dat;

	SegTree(int n_, T t_max)

	{

		int n = 1;

		T_max = t_max;

		while (n < n_)n *= 2;

		for (int i = 0; i < 2 * n - 1; i++)dat.push_back(t_max);

	}

	void update(int k, T a)

	{

		k += n - 1;

		dat[k] = a;

		while (k > 0)

		{

			k = (k - 1) / 2;

			dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);

		}

	}



	//[a,b)

	T query(int a, int b)

	{

		return _query(a, b, 0, 0, n);

	}



private:

	T _query(int a, int b, int k, int l, int r)

	{

		if (r <= a || b <= l)return T_max;

		if (a <= l && r <= b)return dat[k];

		else

		{

			T vl = _query(a, b, k * 2 + 1, l, (l + r) / 2);

			T vr = _query(a, b, k * 2 + 2, (l + r) / 2, r);

			return min(vr, vl);

		}

	}

};





int main()

{

	double a;

	while (cin >> a && a >= 0.0)

	{

		int A;

		double B;

		string ans;



		A = a;

		B = a - A;



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

		{

			ans += (A % 2) + '0';

			A /= 2;

		}



		if (A > 0)

		{

			cout << "NA" << endl;

			continue;

		}



		reverse(ans.begin(), ans.end());

		ans += ".";



		for (int i = 1; i <= 4; i++)

		{

			if (B >= pow(2, i * -1))

			{

				ans += "1";

				B -= pow(2, i * -1);

			}

			else

			{

				ans += "0";

			}

		}



		if (B != 0.0)

		{

			cout << "NA" << endl;

			continue;

		}



		cout << ans << endl;



	}

}

C++: #include<stdio.h>
int main(void)
{
	float a;
	int s,d[13],f,g,h=0,i,j,z;
	while(1){
		scanf("%f",&a);
		z=a;
		if(z<0){
			break;
		}
		for(i=1;i<=12;i++){
			d[i]=0;
		}
		//printf("%f",a);
		f=a*16;
		i=2048;
		//printf("a == %f\n",a*16);
		s=f;
		j=1;
		while(i!=1){
			i=i/2;
			if(i<=f){
				d[j]=f/i;
				//printf("d[%d] = %d %d %d\n",j,d[j],i,f);
				f=f-i;
			}
			j++;
		}
		if(a>=4096){
			printf("NA\n");
			h=1;
			//printf("1111\n");
		}
		if((a*16)-s>0){
			//printf("2222 = %d\n",a*16-s);
			printf("NA\n");
			h=1;
		}
		/*for(i=0;i<12;i++){
			printf("%d\n",d[i]);
		}*/
		if(h==0){
			for(i=0;i<12;i++){
				printf("%d",d[i]);
				if(i==7){
					printf(".");
				}
			}
			printf("\n");
		}
	}
	return 0;
}

C++: #include<stdio.h>
int main()
{
	int x,c,i,k;
float a,y,z,w,q;
	scanf("%f",&a);
	while(a>=0){
		x=a;
		y=a-x;
		z=0;
		c=0;
		w=0;
		k=0;
		k=0;
		if(x>=128){
			z=z+10000000;
			x=x-128;
			k++;
		}
		if(x>=64){
			z=z+1000000;
			x=x-64;
			if(k==0)
			c=1;
			k++;
		}
		if(x>=32){
			z=z+100000;
			x=x-32;
			if(k==0)
			c=2;
			k++;
		}
		if(x>=16){
			z=z+10000;
			x=x-16;
			if(k==0)
			c=3;
			k++;
		}
		if(x>=8){
			z=z+1000;
			x=x-8;
			if(k==0)
			c=4;
			k++;
		}
		if(x>=4){
			z=z+100;
			x=x-4;
			if(k==0)
			c=5;
			k++;
		}
		if(x>=2){
			z=z+10;
			x=x-2;
			if(k==0)
			c=6;
			k++;
		}
		if(x>=1){
			z=z+1;
			x=x-1;
			if(k==0)
			c=7;
			k++;
		}
		
		if(y>=0.5){
			w=w+0.1;
			y=y-0.5;
		}
		if(y>=0.25){
			w=w+0.01;
			y=y-0.25;
		}
		if(y>=0.125){
			w=w+0.001;
			y=y-0.125;
		}
		if(y>=0.0625){
			w=w+0.0001;
			y=y-0.0625;
		}
		
		if(x==0&&y==0){
			for(i=0;i<c;i++){
				printf("0");
			}
		printf("%.4f\n",z+w);
		}
		else{
			printf("NA\n");
		}
	scanf("%f",&a);
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;


char pr[100];

main(){
	double d;
	while(cin>>d){
		if(d<0)break;
		
		
		memset(pr,0,sizeof(pr));
		
		for(int i=0;i<13;i++){
			if(i<8){
				if(d>=pow(2,7-i)){
					d-=pow(2,7-i);
					pr[i]='1';
				}else{
					pr[i]='0';
				}
			}else if(i==8){
				pr[i]='.';
			}else{
				if(d>=pow(2,8-i)){
					d-=pow(2,8-i);
					pr[i]='1';
				}else{
					pr[i]='0';
				}
			}
		}
		
		if(d!=0)puts("NA");
		else puts(pr);
	}
	return 0;
}

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

int main()
{
	double n;
	double c[12];

	c[0] = 128;
	for(int i=1; i<12; i++)
	{
		c[i] = c[i-1]/2;
	}

	while(cin >> n, n>=0)
	{
		int a[12] = {0};

		for(int i=0; i<12; i++)
		{
			if(n>=c[i])
			{
				a[i] = 1;
				n -= c[i];
			}
		}

		if(!n)
		{
			for(int i=0; i<12; i++)
			{
				cout << a[i];
				if(i==7) cout << '.';
			}
			cout << endl;
		}
		else
		{
			cout << "NA" << endl;
		}
	}
}

C++: #include<iostream>
using namespace std;
int main(void)
{
	double a;
	int i;
	int box[12]={0,0,0,0,0,0,0,0,0,0,0,0};
	double nisin[12]={128.0,64.0,32.0,16.0,8.0,4.0,2.0,1.0,0.5,0.25,0.125,0.0625};

	cin >> a;
	while(a>0.0){
		for(i=0;i!=12;i++){
			if(a>=nisin[i]){
				a=a-nisin[i];
				box[i]=1;
			}
		}
		if(a==0.0){
			for(i=0;i!=12;i++){
				cout << box[i];
				if(i==7){
					cout << '.';
				}
			}
		}
		else{ 
			cout << "NA";
		}
		cout << endl;
		cin >> a;
	}
	return 0;
}

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

using namespace std;

int main()
{
	double D;

	while (true)
	{
		cin >> D;

		if (D < 0.0) { break; }

		if (D >= 256.0 || fmod(D * 16.0, 1.0) != 0.0)
		{
			cout << "NA" << endl;
		}
		else
		{
			for (int i = 7; i > -4; i--)
			{
				cout << (int)(D / pow(2, i)) % 2;

				if (i == 0)
				{
					cout << '.';
				}
			}

			cout << endl;
		}
	}

	return 0;
}