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 <cmath>
#include <string>

int main() {
	double a;
	std::string str;
	str.reserve(13);

	while (std::cin >> a) {
		if (a < 0)
			break;

		for (int i = 7; i >= -4; --i) {
			double b = std::pow(2.0, i);
			if (a >= b) {
				a -= b;
				str += '1';
			}
			else
				str += '0';

			if (i == 0)
				str += '.';
		}

		if (a < 0.000001)
			std::cout << str << std::endl;
		else
			std::cout << "NA" << std::endl;

		str.clear();
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define mk make_pair
using namespace std;
int main(){
  double n;
  while(cin>>n,n>=0){
    double m=n-(int)n,b[]={0.5,0.25,0.125,0.0625};
    int a=(int)n;
    string s,d;
    for(int i=1<<7;i>0;i/=2){
      if(a>=i)s+='1',a-=i;
      else s+='0';
    }
    for(int i=0;i<4;i++){
      if(m>=b[i])d+='1',m-=b[i];
      else d+='0';
    }
    if(m<=0.000000001||a)cout<<s<<'.'<<d<<endl;
    else cout<<"NA"<<endl;
  }
}

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

int main()
{
  double n, ans;
  while(1)
  {
    ans = 0;
    cin >> n;
    if(n < 0)
      break;
    
    if(n >= 256)
    {
      cout << "NA\n";
      continue;
    }

    int d;
    int m = (int)n;
    double r = n - m;
    
    for(int i = 0; i <= 8; i++)
    {

      d = m % 2;
      m /= 2;
      ans += d * pow(10, i);
    }
    for(int i = -1; i >= -4; i--)
    {
      d = (int)(r * 2);
      r = r * 2 - d;
      ans += d * pow(10, i);
    }
    if(r > 0.0001)
      cout << "NA\n";
    else
      printf("%013.4f\n", ans);
  }
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    double n;
    while(cin >> n && n >= 0){

        int data[12];
        int m = 128;
        for(int i = 0; i < 8; ++i){
            if(n >= m){
                n -= m;
                data[i] = 1;
            }
            else
                data[i] = 0;
            m /= 2;
        }

        double m2 = 0.5;
        for(int i = 8; i < 12; ++i){
            if(n >= m2){
                n -= m2;
                data[i] = 1;
            }
            else
                data[i] = 0;
            m2 /= 2;
        }

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

   return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#define rep(i,n) for(int i=0;i<(int)n;i++)

using namespace std;


int main()
{
	double a;
	for(cin>>a;a>=0.0;cin>>a)
	{
		int j;
		double k;
		string ans,ans2;
		j=a;
		k=a-j;
		while(j!=0)
		{
			ans+=j%2==1?"1":"0";
			j/=2;
		}
		if(ans.size()>8)
		{
			cout<<"NA"<<endl;
			continue;
		}
		else
		{
			while(ans.size()!=8)ans+="0";
		}
		reverse(ans.begin(),ans.end());
		ans+=".";
		
		
		
		
		int i=1;
		while(k>=0.00001)
		{
			if(k>=(1.0/2.0)/i)
			{
				k=k-(1.0/2.0)/i;
				ans2+="1";
			}
			else
			{
				ans2+="0";
			}
			i++;
			if(ans2.size()>=6)break;
		}
		
		if(ans2.size()>=5)
		{
			cout<<"NA"<<endl;
			continue;
		}
		else
		{
			while(ans2.size()!=4)ans2+="0";
		}
		
		cout<<ans<<ans2<<endl;
		
		
	}
}

C++: #include <cstdio>
using namespace std;
// 00010111.1000

int main(){
    double d;
    while(scanf("%lf",&d), d>=0){
        d*=16;
        int id = d;
        if(d-id!=0 || d>0xFFF) puts("NA");
        else {
            for(int i=0;i<12;i++){
                putchar(id&1<<(11-i) ? '1' : '0');
                if(i==7)putchar('.');
            }
            putchar('\n');
        }
    }
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

string compute(int n,bool &flag){
  string ret ="";
  while(n>0){
    if (n%2 == 1)ret+="1";
    else ret+="0";
    n/=2;
  }
  if (ret.size() > 8){
    flag=false;
    return "";
  }
  flag=true;
  while(ret.size() != 8)ret+="0";
  reverse(ret.begin(),ret.end());
  return ret;
}

string compute2(int m,bool &flag){
  const int aho[4]={5000,2500,1250,625};
  rep(i,(1<<4)){
    int val=0;
    rep(j,4){
      if ( (i&(1<<j)) != 0)val+=aho[j];
    }
    if (val == m){
      string ret="";
      rep(j,4){
	if ( (i&(1<<j)) != 0)ret+="1";
	else ret+="0";
      }
      flag=true;
      return ret;
    }
  }
  flag=false;
  return "";
}

main(){
  int n,m;
  char dummy;
  while(cin>>n>>dummy>>m){
    if (n < 0){
      break;
    }
    m*=1000;
    bool flag;
    string a=compute(n,flag);
    if (!flag){
      cout << "NA" << endl;
    }
    string b = compute2(m,flag);
    if (flag)cout << a <<"." << b << endl;
    else cout << "NA" << endl;
  }
}

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



int main(){
  double power[8]={},sho[5];
  power[0] = 1;  sho[0] = 1;
  for(int i=1;i<8;i++){
    power[i] = power[i-1]*2;
  }
  for(int i=1;i<5;i++){
    sho[i] = sho[i-1]/2;
  }

  while(1){
    double n;
    cin >> n;
    if(n < 0) break;
    int ans[16]={};
    for(int i=0;i<8;i++){
      if(n >= power[7-i]){
	n -= power[7-i];
	ans[i]=1;
      }
    }
    for(int i=0;i<4;i++){
      if(n >= sho[i+1]){
	n -= sho[i+1];
	ans[i+8]=1;
      }
    }
    if(n != 0) cout << "NA\n";
    else{ 
      for(int i=0;i<12;i++){
	cout << ans[i];
	if(i == 7) cout << ".";
      }
      cout << "\n";
    }



  }
}

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

void solve(double x) {
	unsigned char y = (char)x;
	if (y != ((int)x)) {
		cout << "NA" << endl;
		return;
	}
	x -= y;
	int res[4] = {0, 0, 0, 0};
	for (int i = 0; i < 4; i++) {
		x *= 2.;
		res[i] = (int)x;
		x -= res[i];
	}
	if (x > 0) cout << "NA" << endl;
	else {
		for (int i = 8; i >= 0; i--) {
			cout << ((y & (1u << i)) >> i);
		}
		cout << '.';
		for (int i = 0; i < 4; i++) {
			cout << res[i];
		}
		cout << endl;
	}
}

int main () {
	double x;
	while (cin >> x, x >= 0.) {
		solve(x);
	}
	return 0;
}