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 <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
int main()
{
	while(1)
	{
		double n;
		scanf("%lf",&n);
		if(n < 0.0) return 0;
		bool xx[15]={}; int c = 0;
		for(double x=128.0;x>=1.0/16.0;x/=2.0)
		{
			if(n >= x)
			{
				n -= x;
				xx[c] = true;
			}
			c++;
		}
		if(n != 0.0) puts("NA");
		else
		{
			for(int i=0;i<12;i++)
			{
				if(i == 8) printf(".");
				printf(xx[i]?"1":"0");
			}
			puts("");
		}
	}
}

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

int main(){
  double n;

  while(cin >> n , n >= 0){
    string ans = "";

    for(int a = 128 ; a > 0 ; a /= 2){
      if(n == a){
	ans += "1";
	n -= a;
	continue;
      }

      if((int)n / a == 0){
	ans += "0";
      }
      else{
	ans += "1";
	n -= a;
      }
    }
    ans += ".";
    for(int a = 0 ; a < 4 ; a++){
      double b = pow(2.0,-(a+1));

      if(n == b){  
	ans += "1";
	n -= b;
	continue;
      }

      if((int)n / b == 0){
	ans += "0";
      }
      else{
	ans += "1";
	n -= b;
      }
    }
    
    if(!n) cout << ans << endl;
    else cout << "NA" << endl;
  }

  return 0;
}

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.size() > 0 && s[0] != '-')) {

        int n = 0, m = 0;

        if(s.find('.') <= 3 && (s.size() - 1 - s.find('.')) <= M) {
            
            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 < M - (s.size() - s.find('.') - 1); i++)
                m *= 10;
            
            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 / 10000;
                ms[i] = '0' + d;
                if(c == 10000 || c == 0)
                    break;
                else if(c > 10000)
                    c -= 10000;
            }
            if(c == 10000 || c == 0) {
                c = d = n;
                idx = 7;
                ns = "00000000";
                while(c > 1) {
                    d = c % 2;
                    c /= 2;
                    if(idx >= 0)
                        ns[idx--] = d + '0';
                }
                ns[idx] = '0' + c;
                cout << ns << "." << ms <<  endl;
            } else {
                cout << "NA" << endl;
            }
        } else {
            cout << "NA" << endl;
        }
    }
}

C++: #include <bits/stdc++.h>
using namespace std;

int main()
{
	double val;

	while ( cin >> val, val > 0 ) {
		val *= 16;
		if ( fabs(val - (int)val) < 1e-6 ) {
			int dat = val;
			for ( int i = 11; i >= 0; i-- ) {
				cout << ((dat & (1 << i)) >> i);
				if ( i == 4 ) cout << ".";
			}
			cout << endl;
		} else {
			cout << "NA" << endl;
		}
	}

	return ( 0 );
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  double n;
  double array[] = { 256,128,64,32,16,8,4,2,1,0.5,0.25,0.125,0.0625 };
  while(cin>>n,n>0){
  string s = "";
   for(int i = 0 ; i < 13 ; i ++){
    if(i == 9)s += '.';
    if(n>=array[i]){
      n -= array[i]; 
      s += "1";
    }else{
      s += "0";
    }
  }
  if(n==0)cout<<s<<endl;
  else cout<<"NA"<<endl;
}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
std::vector<int> dparttobinary(double n){
	std::vector<int> vec;
	while(n != 0){
		n *= 2;
		int ipart = (int)n;
		vec.push_back(ipart);
		n = n - (double)ipart;
	}
	return vec;
}

std::vector<int> iparttobinary(int n){
	std::vector<int> vec;
	while(n != 0){
		vec.push_back(n % 2);
		n /= 2;
	}
	std::reverse(vec.begin(), vec.end());
	return vec;
}

int main(){
	double n;
	while(std::cin >> n, n > 0){
		int ipart = (int)n;
		double dpart = n - (double)ipart;
		std::vector<int> dvec = dparttobinary(dpart),
			ivec = iparttobinary(ipart);
	
		if(dvec.size() <= 4 && ivec.size() <= 8){
			for(int i=8-ivec.size();i;i--)
				std::cout << "0";
			for(int i=0;i<ivec.size();i++)
				std::cout << ivec[i];
			std::cout << ".";
			for(int i=0;i<dvec.size();i++)
				std::cout << dvec[i];
			for(int i=4-dvec.size();i;i--)
				std::cout << "0";
			std::cout << "\n";
		}else{
			std::cout << "NA\n";
		}
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
	double num;
	while(cin>>num,num>0){
	    string str;
		for(double i=128;i>0.03125;i/=2){
			str+=int(num/i)+'0';
			if(num/i>=1)num-=i;
			if(i==1)str+='.';
		}
		if(num/0.03125>0)cout<<"NA"<<endl;
		else cout<<str<<endl;
	}
}

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 >= 256 ) {
			cout << "NA" << endl;
			continue;
		}
		flag = true;
		if (point != 0) {
			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;
			}
		}
		else for (int i = 0; i < 4; ++i)que.push(0);


		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;
}