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<string>
using namespace std;

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

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

#define EPS 1e-7

string tostr(int arg){
	string ret = "00000000.0000";
	int pos = 0;
	while(arg > 0){
		if(arg & 1){
			ret[12-pos] = '1';
		}
		arg >>= 1;
		pos++;
		if(pos == 4) pos++;
	}
	return ret;
}

int main(){
	vector<double> fs;
	
	double d;
	while(cin >> d && d >= 0){
		int ret=-1;
		for(int i=0;i<(1 << 12);i++){
			if(i == d*16){
				ret = i;
				break;
			}
		}
		if(ret == -1 || d > 255 + 0.5 + 0.25 + 0.125 + 0.0625){
			cout << "NA" << endl;
		}else{
			cout << tostr(ret) << endl;
		}
	}
}

C++: #include <stdio.h>

int main(void){
	double x;
	int m,n;
	char bin[14];
	
	bin[8] = '.';
	bin[13] = 0;
	while (scanf("%lf", &x), x>=0){
		x -= (n = x);
		for (int i=0; i<8; i++){
			bin[7-i] = '0'+(n%2);
			n /=2;
		}
		for (int i=0; i<4; i++){
			bin[9+i] = '0' + ((x*=2)>0);
			x -=m=x;
		}
		if (n || x>0){
			puts("NA");
			continue;
		}
		printf("%s\n",bin);
	}
	
	return 0;
}

C++: #include<iostream>
#include<bitset>
#include<stack>
#include<queue>
using namespace std;
void reset(queue<int>& que, stack<int>& st) {
	while (que.size())que.pop();
	while (st.size())st.pop();
	return;
}
int main() {
	double n,point;
	int in;
	bool flag;
	queue<int>que;
	stack<int>st;
	while (1) {
		reset(que,st);
		cin >> n;
		if (n < 0)break;
		in = (int)n;
		point = (double)n-in;
		if (n >= 356 || (point!=0&&point <= 0.0625)) {
			cout << "NA" << endl;
			continue;
		}
		flag = true;
		for (int i = 0; i < 4; ++i) {
			point *= 2;
			if (point== 1.0) {
				flag = false;
				que.push(1);
			}
			else {
				if ((int)point == 1) {
					que.push(1);
					point -= 1;
				}
				else que.push(0);
			}
		}
		if (flag) {
			cout << "NA" << endl;
			continue;
		}

		for (int i = 0; i < 8;++i) {
			if (in % 2 == 0) {
				st.push(0);
			}
			else {
				st.push(1);
			}
			in /= 2;
		}
		while (st.size()) {
			cout << st.top();
			st.pop();
		}cout << ".";
		while (que.size()) {
			cout << que.front();
			que.pop();
		}
		cout << endl;

	}
	return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

int A = 0, B = 0, K = 0, T = 0, W = 0, N = 0, H = 0;
int n = 0;
double L = 0;
double S = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;

string C;
string sA, strB;
vector<vector<char>> map;
vector<double> num;
vector<string> str;

int sum = 0;


double tempd = 0.0;



void input() {
	while (true) {
		CI tempd;
		if (tempd < 0.0) {
			break;
		}
		num.push_back(tempd);
	}

	return;
}


int main(void) {
	double deci;
	int numd;
	vector<int> int_array;
	vector<int> deci_array;
	input();

	for (int i = 0; i < num.size(); i++) {
		numd = num[i];
		deci = num[i] - (double)numd;

		while (true) {
			if (numd == 0) {
				break;
			}
			int_array.push_back(numd % 2);
			numd /= 2;
		}
		if (int_array.size() > 8) {
			CO "NA" E
				int_array.clear();
			int_array.shrink_to_fit();
			deci_array.clear();
			deci_array.shrink_to_fit();
			continue;
		}

		bool flag = false;
		int nx = 0;
		while (true) {
			if (deci == (double)(int)deci) {
				break;
			}
			nx++;
			deci *= 2;
			deci_array.push_back((int)deci % 10);


			if (deci_array.size() > 4) {
				CO "NA" E
				int_array.clear();
				int_array.shrink_to_fit();
				deci_array.clear();
				deci_array.shrink_to_fit();
				flag = true;
				break;
			}
		}
		if (flag) {
			flag = false;
			continue;
		}


		for (int j = 0; j < 8 - int_array.size(); j++) {
			CO 0;
		}
		for (int j = int_array.size() - 1; j >= 0; j--) {
			CO int_array[j];
		}
		CO ".";
		for (int j = 0; j < deci_array.size(); j++) {
			CO deci_array[j];
		}
		for (int j = 0; j < 4 - nx; j++) {
			CO 0;
		}
		CO "\n";
		int_array.clear();
		int_array.shrink_to_fit();
		deci_array.clear();
		deci_array.shrink_to_fit();
	}


	return 0;
}

C++: #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>

using namespace std;

int main(){

	char ans_upper[9],ans_under[5];
	int upper,under,S;
	double number;

	while(true){
		scanf("%lf",&number);
		if(number < 0)break;

		upper = (int)floor(number);

		if(upper >= 256){
			printf("NA\n");
			continue;
		}

		S = 128;

		for(int i = 0; i < 8; i++){
			if(upper >= S){
				ans_upper[i] = '1';
				upper -= S;
			}else{
				ans_upper[i] = '0';
			}
			S /= 2;
		}

		ans_upper[8] = '\0';


		under = 10000*(number - (int)floor(number));

		for(int i = 0; i < 4; i++){
			under *= 2;
			if(under/10000 >= 1){
				ans_under[i] = '1';
			}else{
				ans_under[i] = '0';
			}
			under %= 10000;
		}

		if(under != 0){
			printf("NA\n");
			continue;
		}

		ans_under[4] = '\0';

		printf("%s.%s\n",ans_upper,ans_under);

	}

	return 0;
}

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

using namespace std;

double eps = 1.0e-8;
bool eq(double a, double b){
  return abs(a-b) < eps;
}
int main()
{
  
  while(true){
    double p;
    bool b[4] = {false,};
    cin >> p;
    if( p < 0 ) break;
    int d = (int)floor(p+eps);
    
    p = p - d;
    double c = 0.5;
    bool na=false;
    int n = 0;

    bitset<32> bi(d);

    while( true ){
      if( eq(p,0) ) break;
      if( p >= c ){
	p -= c;
	b[n] = true;
	if( eq(p,0) ) break;
      }
      ++n;
      c *= 0.5;
      if( n == 5 ){
	na = true;
	break;
      }
    }
    
    if( d > 255 ) na = true;

    if( na ){
      cout <<"NA"<<endl;
    }else{
      for(int i = 0; i < 8; ++i){
	cout << (int)bi[7-i];
      }
      cout << '.';
      for(int i = 0; i < 4; ++i){
	if( b[i] ){
	  cout << '1';
	}else{
	  cout << '0';
	}
      }
      cout << endl;
    }
    
  }
  return 0;
}