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>

bool ans[12];
double b[12]={128,64,32,16,8,4,2,1,0.5,0.25,0.125,0.0625};
double n;

void solve(){
	for(int i=0; i<12; i++){
		if(n-b[i] >= 0){
			n -= b[i];
			ans[i] = true;
		}else
			ans[i] = false;
	}
}

void show(){
	if(n)
		std::cout << "NA";
	else{
		for(int i=0; i<12; i++){
			if(i==8)
				std::cout << '.';
			if(ans[i])
				std::cout << 1;
			else
				std::cout << 0;
		}
	}
	std::cout << std::endl;
}

int main(){
	while(true){
		std::cin >> n;
		if(n<0)
			return 0;
		solve();
		show();
	}
	return 0;
}

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

int main() {
	double d;
	while(cin>>d,d>=0){
		double k=128;
		bool b[15];
		for(int i=0;i<12;i++){
			if(d>=k){
				d-=k;
				b[i]=1;
			}
			else b[i]=0;
			k/=2;
		}
		if(d!=0)cout<<"NA\n";
		else{
			for(int i=0;i<8;i++)cout<<b[i];
			cout<<'.';
			for(int i=0;i<4;i++)cout<<b[i+8];cout<<endl;
		}
	}
	return 0;
}

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

#define DBG(x) cerr << #x << " = " << x << endl

template <class T, class U> 
T lexical_cast(const U& from) {
  stringstream ss;
  ss << from;
  T to;
  ss >> to;
  return to;
}

int main() {
  while(true) {
    string s; cin >> s;
    if(s[0] == '-') break;
    string ax, bx;
    for(int i = 0; i < (int)s.size(); ++i) {
      if(s[i] == '.') {
        ax = s.substr(0, i);
        bx= "0." + s.substr(i + 1);
      }
    }
    if(ax == "") ax = s;
    string as, bs;
    int a = lexical_cast<int>(ax);
    double b = lexical_cast<double>(bx);
    while(a > 0 && as.size() <= 8) {
      as.push_back('0' + a % 2);
      a /= 2;
    }
    reverse(as.begin(), as.end());
    while(abs(b) > 1e-8 && bs.size() <= 4) {
      bs.push_back('0' + (int)(b * 2));
      b *= 2;
      if(b - 1.0 > -1e-8) b -= 1.0;
    }
    if(as.size() <= 8 && bs.size() <= 4) {
      for(int i = 0; i < 8 - as.size(); ++i) cout << "0";
      cout << as << "." << bs;
      for(int i = 0; i < 4 - bs.size(); ++i) cout << "0";
      cout << endl;
    }
    else {
      cout << "NA" << endl;
    }
  }
}

C++: #include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    double n;
    int tmp_i;
    double tmp_f;
    double comp;
    cin>>n;
    while( n>=0.0 ){
        char binari[20],temp;
        comp = 0.5;
        tmp_i = (int)n;
        tmp_f = n-(float)tmp_i;
        for(int i=0;i<8;i++){
            if(tmp_i % 2 == 0){
                binari[i] = '0';
            }else{
                binari[i] = '1';
            }
            tmp_i = tmp_i / 2;
        }
        for(int i=0;i<4;i++){
            temp = binari[i];
            binari[i] = binari[8-i-1];
            binari[8-i-1] = temp;
        }
        binari[8] = '.';
        for(int i=0;i<4;i++){
            if(tmp_f >= comp){
                binari[8+i+1] = '1';
                tmp_f = tmp_f - comp;
            }else{
                binari[8+i+1] = '0';
            }
            comp = comp / 2;
        }
        if( ((float)tmp_i + tmp_f) == 0.0){
            cout<<binari<<"\n";
        }else{
            cout<<"NA\n";
        }
        cin>>n;
    }
    return 0;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main(void)
{
	double a;
	int i;
	char 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;
		for(i=0;i!=12;i++){
			box[i]='0';
		}
		cin >> a;
	}
	return 0;
}

C++: /*
	AOJ_0220:Binary Digit A Doctor Loved
*/
#include	<iostream>
#include	<string>

using namespace std;

string convert_toDigit(double);

int main(void) {
	double input;

	while (1) {
		cin >> input;

		if (input < 0.0) { break; }
		cout << convert_toDigit(input) << endl;
	}
	return 0;
}

string convert_toDigit(double targetNum) {
	string ans;
	double progressNum = 128.0;

	if (targetNum > 128.0) { return "NA"; }

	while (progressNum > 0.03125 || targetNum != 0.0) {

		if (targetNum >= progressNum) {
			ans += '1';
			targetNum -= progressNum;
		} else {
			ans += '0';
		}
		progressNum /= 2;
		if (progressNum == 0.5) { ans += '.'; }
	}
	if (targetNum == 0.0) { return ans; }
	else { return "NA"; }
}

C++: #include<cstdio>
#include<cstring>
using namespace std;
int main(){
  
  double n;
  scanf("%lf",&n);
  while(n >= 0){
    char c[20]={""};
    for(double i=128;i>=0.0625;i=i/2){
      if(n >= i){
	n -= i;
	strcat(c,"1");
      } else strcat(c,"0");
      if(i == 1) strcat(c,".");
    }
    
    if(n == 0.00000) printf("%s\n",c);
    else printf("NA\n");
    scanf("%lf",&n);
  }
  return (0);
}

C++: #include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000009;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double bin;

  cin >> bin;
  while(bin >= 0){
    string ans;
    int bin_s = (int)bin;
    
    // 整数部
    while(bin_s != 0){
      ans += bin_s % 2 == 0? "0" : "1";
      bin_s /= 2;
    }    
    for(int i = ans.size();i < 8;i++){
      ans += "0";
    }
    
    reverse(ans.begin(), ans.end());
    ans += ".";

    // 小数部
    int cnt = 0;
    double bin_m = bin - (int)bin;
    
    while(cnt < 100 && bin_m != 0){
      cnt++;
      bin_m *= 2;
      ans += (int)bin_m == 1? "1" : "0";
      bin_m -= (int)bin_m;
    }
    
    for(int i = cnt;i < 4;i++){
      ans += "0";
    }

    if(cnt <= 4){
      cout << ans << endl;
    }else{
      cout << "NA" << endl;
    }
    cin >> bin;
  }
  return 0;
}

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

int main( void )
{
    double input;
    double eps = 1e-12;

    while ( cin >> input && ( input < 0.0 == false ) )
    {
        int     p = static_cast <int>( floor( input ) );
        double  q = input - p;
        double  test = q;
        bool    NA = false;

        if ( p >= ( 1 << 8 ) ) NA = true;
        for ( int i = 0; i < 4; i++ ) test *= 2.0;
        if ( ( fabs( floor( test ) - ceil( test ) ) < eps ) == false ) NA = true;

        if ( NA )
        {
            cout << "NA" << endl;
        }
        else
        {
            for ( int i = 7; i >= 0; i-- ) cout << ( p & 1 << i ? 1 : 0 );
            cout << ".";
            test = q;
            for ( int i = 0; i < 4; i++ )
            {
                q *= 2.0;
                if ( ( q < 1.0 ) == false )
                {
                    cout << "1";
                    q -= 1.0;
                }
                else cout << "0";
            }
            cout << endl;
        }
    }

    return 0;
}