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

double mul[] = {0.0625, 0.125, 0.25, 0.5};

int main(){
  double x;

  while(cin >> x, x != -1){
    int a = (int)floor(x);

    if(a >= (1 << 8)){
      cout << "NA" << endl;
      continue;
    }

    int bit = -1;
    double b = x - a;

    for(int i = 0; i < (1 << 4); i++){
      double sum = 0;
      for(int j = 0; j < 4; j++){
        if(!(i & (1 << j))) continue;
        sum += mul[j];
      }
      if(sum == b){
        bit = i;
        break;
      }
    }

    if(bit == -1){
      cout << "NA" << endl;
      continue;
    }

    for(int i = 7; i >= 0; i--){
      cout << (a & (1 << i) ? 1 : 0);
    }
    cout << ".";
    for(int i = 3; i >= 0; i--){
      cout << (bit & (1 << i) ? 1 : 0);
    }
    cout << endl;
  }
}

C++: #include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int n;
  string s,t,u;
  while(cin>>s&&s[0]!='-'){
    n=atoi(s.substr(0,s.find(".")).c_str());
    if(n>255){
      cout<<"NA"<<endl;
      continue;
    }
    t=u="0000";
    for(i=1;i<(int)(s.length()-s.find("."));i++)
      t[i-1]=s[s.find(".")+i];
    if(t[0]>'4'){
      t[0]-=5;
      u[0]++;
    }
    if(t[0]>'1'&&t[1]>'4'){
      t[0]-=2;
      t[1]-=5;
      u[1]++;
    }else if(t[0]>'2'){
      t[0]-=3;
      t[1]+=5;
      u[1x]++;
    }
    if(t[0]>'0'&&t[1]>'1'&&t[2]>'4'){
      t[0]-=1;
      t[1]-=2;
      t[2]-=5;
      u[2]++;
    }
    if(t[1]>'5'&&t[2]>'1'&&t[3]>'4'){
      t[1]-=6;
      t[2]-=2;
      t[3]-=5;
      u[3]++;
    }
    if(t!="0000"){
      cout<<"NA"<<endl;
      continue;
    }
    for(i=0;i<8;i++){
      cout<<n/(int)pow(2,7-i);
      n%=(int)pow(2,7-i);
    }
    cout<<"."<<u<<endl;
  }
  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 <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>

using namespace std;

typedef long long ll;
typedef pair<int,int>P;

#define INF 2<<29
#define F first
#define S second

int main(){
  double a;
  double temp;
  char ans1[8];
  char ans2[4];

  while(1){
    scanf("%lf",&a);
    if(a<0) break;

    for(int i=7;i>=0;i--){
      temp=(double)(1<<i);
      if(temp<=a){
	a-=temp;
	ans1[7-i]='1';
      }else{
	ans1[7-i]='0';
      }
    }
    
    for(int i=1;i<=4;i++){
      temp=pow(2.0,-(double)i);
      if(temp<=a){
	a=a-temp;
	ans2[i-1]='1';
      }else{
	ans2[i-1]='0';
      }
    }
    
    if(a!=0){
      printf("NA\n");
    }else{
      for(int i=0;i<8;i++){
	printf("%c",ans1[i]);
      }
      putchar('.');
      for(int i=0;i<4;i++){
	printf("%c",ans2[i]);
      }
      putchar('\n');
    }
  }
	       
  return (0);
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;

int main()
{
	string str;
	while (cin >> str) {
		if (str[0] == '-') break;
		
		if (str.find('.') == string::npos) {
			puts("NA");
			continue;
		}
		
		string A = str.substr(0, str.find('.'));
		string B = str.substr(str.find('.') + 1, str.size());
		
		bool ok = true;
		int ans[12] = {};
		
		if (A.size() > 5) {
			if (A[0] == '0') {
				int z = 0;
				while (A[z] == '0') z++;
				
				if (z == A.size()) A = "0";
				else A = A.substr(z);
			}
			
			if (A.size() > 5) ok = false;
		}
		else if (*(B.end() - 1) == '0') {
			int z = B.size() - 1;
			while (B[z] == '0') z--;
			z++;
			
			B = B.substr(0, z);
		}
		if (B.size() > 7) ok = false;
		
		if (ok) {
			ll a = atol(A.c_str());
			while (B.size() < 7) B += '0';
			ll b = atol(B.c_str());
			
			REP(i, 8) {
				ans[7 - i] = a % 2;
				a /= 2;
			}
			
			if (a > 0) ok = false;
			else {
			
				REP(i, 4) {
					b *= 2;
					ans[8 + i] = b / 10000000;
					b %= 10000000;
				}
				
				if (b > 0) ok = false;
			}
		}
		
		if (ok) {
			REP(i, 8) putchar('0' + ans[i]);
			putchar('.');
			FOR(i, 8, 12) putchar('0' + ans[i]);
			puts("");
		}
		else puts("NA");
	}
	return 0;
}


// 5

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

int main()
{
	double f;
	while (scanf("%lf", &f), f != -1.0){
		f *= 16;
		if (f - (int)f > 0.0){
			puts("NA");
		}
		else {
			int n = f;
			string str;
			for (int i = 0; i < 12; i++){
				str += (char)(n & 1) + '0';
				if (i == 3) str += '.';
				n /= 2;
			}
			reverse(str.begin(), str.end());
			cout << str << endl;
		}
	}
	return 0;
}