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 <cmath>

using namespace std;

int main()
{
	for(char buf[80];gets(buf),buf[0]!='-';){
		double x; sscanf(buf,"%lf",&x);
		
		if(x>=256){
			puts("NA");
			continue;
		}
		if(fmod(x*16,1)>0){
			puts("NA");
			continue;
		}
		int a=x,b=fmod(x,1)*16;
		for(int i=0;i<8;i++)
			putchar('0'+(a>>7-i&1));
		putchar('.');
		for(int i=0;i<4;i++)
			putchar('0'+(b>>3-i&1));
		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;
		
		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() > 3 || B.size() > 4) ok = false;
		
		if (ok) {
			int a = atoi(A.c_str());
			while (B.size() < 4) B += '0';
			int b = atoi(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 / 10000;
					b %= 10000;
				}
				
				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 <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)>=1.0);
			x -=m=x;
		}
		if (n || x>0){
			puts("NA");
			continue;
		}
		printf("%s\n",bin);
	}
	
	return 0;
}

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

int main(){
	double a;
	while(scanf("%lf", &a), a >= 0.0){
		a *= 16.0;
		int b = a;
		if(a != b || b >= (1 << 12)){
			puts("NA");
		}
		else{
			for(int i = 11; i >= 0; --i){
				putchar((b >> i & 1) + '0');
				if(i == 4){ putchar('.'); }
			}
			puts("");
		}
	}
}

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

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cmath>
#include<cstring>
using namespace std;

int main(){
  double n,temp;

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

    if((int)(n*10000)%625!=0) printf("NA\n");
    else{
      for(int i=7;i>=-4;i--){
	temp=pow(2,(double)i);
	if(n>=temp){
	  n-=temp;
	  printf("1");
	}else{
	  printf("0");
	}
	if(i==0) printf(".");
      }
      printf("\n");
    }
  }
  return 0;
}

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

string decToBin(float n){
	string binInteger, binDecimal;
	int decInteger;
	float decDecimal;
	ostringstream oss;
	
	decInteger = floor(n);
	decDecimal = n - decInteger;
	
	while(decInteger){
		binInteger += '0'+(decInteger%2);
		decInteger /= 2;
	}
	reverse(binInteger.begin(),binInteger.end());
	if(binInteger.length()>8)return "NA";
	
	while(decDecimal!=1.0){
		decDecimal = (decDecimal-floor(decDecimal))*2;
		binDecimal += '0'+floor(decDecimal);
	}
	if(binDecimal.length()>4)return "NA";
	
	
	oss<<setfill('0')<<setw(8)<<binInteger
	<<"."
	<<left<<setw(4)<<binDecimal;
	
	return oss.str();
}

int main() {
	float n;
	while(cin>>n,n>=0.0){
		cout<<decToBin(n)<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main() {

    double num;

    while(cin>>num,num>0){

        string str;

        for(double i=128,a;i>0.03125;i/=2){

            str+=int(a=num/i)+'0';

            if(a>=1)num-=i;

            if(i==1)str+='.';

        }

        if(num>0)cout<<"NA"<<endl;

        else cout<<str<<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){
        string input;
        cin >> input;
        if(input[0]=='-')break;

        int dot_i;
        for(int i=0;i<input.size();i++){
            if(input[i]=='.'){
                dot_i = i;
                break;
            }
        }

        int p=1, a=0, b=0;
        for(int i=dot_i-1;i>=0;i--){
            a += (input[i]-'0') * p;
            p *= 10;
        }
        p = 1000;
        for(int i=dot_i+1;i<input.size();i++){
            b += (input[i]-'0') * p;
            p /= 10;
        }

        string a_str = "00000000", b_str = "0000";
        for(int i=0;i<8&&a>0;i++){
            a_str[7-i] += a&1;
            a >>= 1;
        }
        p = 5000;
        for(int i=0;i<4&&b>0;i++){
            b_str[i] += b / p;
            b %= p;
            p /= 2;
        }

        if (a>0||b>0){
            cout << "NA" << endl;
        }else{
            cout << a_str << "." << b_str << endl;
        }
    }

    return 0;
}

C++: #include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;

void func(int a, int n)
{
	int num[8];
	rep(i, n){
		num[i] = a%2;
		a /= 2;
	}
	rep(i, n)
		printf("%d", num[n-1-i]);
}

int main()
{
	char tmp[128];
	while(scanf("%s", tmp)){
		int a, b=0;
		sscanf(tmp, "%d", &a);
		if(a < 0)
			break;
		
		string str = tmp;
		int id = str.find('.');
		if(id != string::npos){
			string sub = str.substr(id+1);
			while(sub.size() < 4) sub += '0';
			b = atoi(sub.c_str());
		}
		
		if(a>=256 || b%625!=0)
			puts("NA");
		else{
			func(a, 8);
			putchar('.');
			func(b/625, 4);
			puts("");
		}
	}
	return 0;
}