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 <sstream>
#include <vector>
using namespace std;

#define EPS (1e-8)
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EQ(a,b) (abs(a-b)<EPS)
#define pb push_back

double n;

string i2s(int i) {
  stringstream ss;
  ss<<i;
  return ss.str();
}

void solve() {
  int real; double imag = n;
  real = (int)imag;
  imag -= (double)real;
  string re, im;
  
  // real
  while (1) {
    if (real / 2 == 0) {
      re.insert(0, "1");
      break;
    }
    if (real % 2) {
      re.insert(0, "1");
    } else {
      re.insert(0, "0");
    }
    real /= 2;
  }
  
  // imag
  vector<double> ds;
  ds.pb(imag);
  while (1) {
    imag *= 2;
    
    bool flag = false;
    rep(i,ds.size()) if (EQ(imag, ds[i])) flag = true;
    if (flag) break;
    
    ds.pb(imag);
    if (imag >= 1.0) {
      im += "1";
      imag -= 1.0;
    } else {
      im += "0";
    }
  }
  if (re.size() > 8 || im.size() > 4) {
    cout<<"NA"<<endl; return;
  }
  while (im.size()!=4) im+="0";
  while (re.size()!=8) re.insert(0,"0");
  cout<<re<<"."<<im<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    if (n < 0) break;
    solve();
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define rep(I,N) for(int I = 0; I < (int)(N); I++)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}
int main(void){
	double num;
	while(cin >> num){
		int cnt = -1;
		do{
			cnt++;
			num--;
		}while(num >= 0);
		bitset<8> value(cnt);
		num++;
		while(ceil(num) != floor(num)){
			num *= 10;
		}
		int x = num;
		int x_cnt = 0;
		if((int)num % 5 == 0){
			while(x != 1){
				x_cnt++;
				x /= 5;
			}
		}
		if((int)num % 5 != 0 || cnt > 255 || x_cnt >= 5){
			double a;
			cout << "NA" << endl;
			while(cin >> a){
				if(a < 0)return 0;
				cout << "NA" << endl;
			}
		}
		bitset<4> deci(x_cnt);
		cout << value << ".";
		bool b[4];
		for(int j = 0, i = 3; j < 4; j++, i--){
			 b[i] = deci[j];
			 cout << b[i];
		}
		cout << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#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 all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	double in;
	while(cin>>in,in+1){
		string s="";
		rep(i,8){
			int h=in/pow(2,7-i);
			s+=(char)(h+'0');
			if(h)in-=pow(2,7-i);
		}
		s+=".";
		rep(i,4){
			int h=in/pow(2,-(i+1));
			s+=(char)(h+'0');
			if(h)in-=pow(2,-(i+1));
		}
		if(in)cout<<"NA"<<endl;
		else cout<<s<<endl;
	}
}

C++: #include<iostream>
using namespace std;
int main(){
	double n;
	while(true){
		cin>>n;
		if(n<0.0)break;
		bool na=false;
		if(n>128.0)na=true;
		int x=n/(0.25*0.5);
		if(x*(0.25*0.5)!=n)na=true;
		if(na==true)
			cout<<"NA"<<endl;
		else{
		int bit=n*8;
		int ans[12];
		for(int j=0;j<12;j++)
			ans[j]=(bit>>j)&1;
		for(int j=11;j>=0;j--){
			cout<<ans[j];
			if(j==4)cout<<".";
		}
		cout<<endl;
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
void solve(int,int);
int main(){
  double n,sn;
  while(1){
    cin >> n;
    if(n==-1.0) break;
    sn = n * 16;
    if(sn!=(int)sn || sn>=4096) cout << "NA";
    else solve((int)sn,0);
    cout << endl;
  }
}
void solve(int sn,int p){
  if(p == 12) return;
  solve(sn/2,p+1);
  if(p == 3) cout << ".";
  cout << sn % 2;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

//n??????
//Radix r;
//cout << r.to(n, 4) << endl;
class Radix {
private:
	const char* s;
	int a[128];
public:
	Radix(const char* s = "0123456789ABCDEF") : s(s) {
		for (int i = 0; s[i]; i++) a[(int)s[i]] = i;
	}
	string to(long long p, int q) {
		if (!p) return "0";
		char t[64] = {};
		int i;
		for (i = 62; p; i--) {
			t[i] = s[p % q];
			p /= q;
		}
		return string(t + i + 1);
	}
	string to(const string &t, int p, int q) {
		return to(to(t, p), q);
	}
	long long to(const string &t, int p) {
		long long sm = a[(int)t[0]];
		for (int i = 1; i < (int)t.length(); i++)
			sm = sm * p + a[(int)t[i]];
		return sm;
	}
};

signed main() {
	for (double n; cin >> n&&n >= 0;) {
		if ((int)n >= pow(2, 8)) { cout << "NA" << endl; continue; }
		Radix r;
		string a = r.to((int)n, 2);
		string b = "";
		n -= (int)n;
		rep(i, 0, 4) {
			n *= 2;
			b += to_string((int)n);
			n -= (int)n;
		}
		if (n != 0) { cout << "NA" << endl; continue; }
		cout << setfill('0') << setw(8) << a << "." << b << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	double dn;
	double list[4] = {0.5, 0.25, 0.125, 0.0625};
	string sm;
	while(cin >> dn, dn >= 0){
		int n = (int)dn;
		double m = dn-n;
		bitset<8> nn(n);
		bool pm[4] = {false};

		if(n > 255){
			cout << "NA" << endl;
			continue;
		} 

		for(int i = 0; i < 4; i++){
			if(m >= list[i]){
				m-=list[i];
				pm[i] = true;
			}
		}
		if(m != 0){
			cout << "NA" <<endl;
			continue;
		}
		cout << nn << ".";
		for(int i = 0; i < 4; i++){
			cout << pm[i];
		}
		cout << endl;

	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}