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 <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  double n;
  while (cin >> n, n >= 0.0) {
    if (n >= (1 << 8)) {
      cout << "NA" << endl;
      continue;
    }
    bitset<8> bit((int)n);
    n -= (int)n;
    string s = "";
    for (int i = 0; i < 4; i++) {
      n *= 2;
      s += (n >= 1.0) + '0';
      n -= (int)n;
    }
    if (n) {
      cout << "NA" << endl;
      continue;
    }
    cout << bit << "." << s << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main(void){
	double n;
	while(1){
		string ans = "";
		cin >> n;
		if(n < 0){
			break;
		}
		for(int i = 8;i >= -4;i--){
			if(n >= pow((double)2,(double)i)){
				ans += '1';
				n -= pow((double)2,(double)i);
			}else{
				ans += '0';
			}
			if(i == 0){
				ans += '.';
			}
		}
		if(n == 0){
			cout << ans << endl;
		}
		else{
			cout << "NA" << endl;
		}
	}

	return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
  double in;
  while(cin>>in,in!=-1){
    if(in>128){cout<<"NA"<<endl;continue;}
    cout<<(64<=in&&in<128?1:0);
    if(64<=in)in-=64;
    cout<<(32<=in&&in<64?1:0);
    if(32<=in)in-=32;
    cout<<(16<=in&&in<32?1:0);
    if(16<=in)in-=16;
    cout<<(8<=in&&in<16?1:0);
    if(8<=in)in-=8;
    cout<<(4<=in&&in<8?1:0);
    if(4<=in)in-=4;
    cout<<(2<=in&&in<4?1:0);
    if(2<=in)in-=2;
    cout<<(1<=in&&in<2?1:0);
    if(1<=in)in-=1;
    cout<<".";
    cout<<(0.5<=in&&in<1?1:0);
    if(0.5<=in)in-=0.5;
    cout<<(0.25<=in&&in<0.5?1:0);
    if(0.25<=in)in-=0.25;
    cout<<(0.125<=in&&in<0.25?1:0);
    if(0.125<in)in-=0.125;
    cout<<(0.0625<=in&&in<0.125?1:0);
    if(0.0625<in)in-=0.0625;
    cout<<endl;
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
main(){
  double n;
  int banti;
  int seisu,syousu;
  while(1){
    char seisuu[9];
    char syousuu[5];
    strcpy(seisuu,"00000000");
    strcpy(syousuu,"0000");
    cin>>n;
    if(n<0){
      break;
    }
    seisu=0;
    syousu=0;
    banti=0;
    for(int i=128;i!=0;i/=2){
      if(n-(double)i>=0){
	seisuu[banti]='1';
	seisu++;
	n-=(double)i;
      }
      if(i!=1){
	seisu=seisu<<1;
	banti++;
      }
    }
    banti=0;
    for(int i=2;i!=32;i*=2){
      if(n-(double)(1/(double)i)>=0){
	syousuu[banti]='1';
	syousu++;
	n-=(double)(1/(double)i);
      }
      if(i!=16){
	syousu=syousu<<1;
	banti++;
      }
    }
    if(n==0){
      cout<<seisuu<<'.'<<syousuu<<endl;
    }
    else{
      cout<<"NA"<<endl;
    }
  }
}

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

#define IPS 1e-10

int main() {
    double n, d;
    int b[12];

    while (cin >> n) {
        if (n < 0) break;
        if (255.9375 < n) goto NA;
        fill(b, b+12, 0);
        d = 128;
        for (int i = 0; n > IPS && i < 12; i++) {
            b[i] = n / d;
            n -= b[i] * d;
            d *= 0.5;
        }
        
        if (n > IPS) goto NA;
        for (int i = 0; i < 12; i++) {
            cout << b[i];
            if (i == 7) cout << '.';
        }
        cout << endl;
        continue;

        NA:
        cout << "NA" << endl;
    }
    return 0;
}

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

bool seisuu(double a) {
	int b = a;
	double c = b;
	return a == c;
}
int main() {
	double a;
	while (cin >> a, a >= 0) {
		a *= 16;
		if (seisuu(a) && a < (1 << 12)) {
			int b = a;
			for (int i = 0,c=(1<<11); i < 12; i++,c>>=1) {
				if (i == 8)cout << '.';
				if (b&c)cout << 1;
				else cout << 0;
			}
			cout << endl;
		}
		else puts("NA");
	}
}

C++: #include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

string n;
int stoi(const string s) {
    int res;
    stringstream ss;
    ss << s;
    ss >> res;
    return res;
}
bool flag;
void split(string s,string& a, string& b) {
    int i=0;
    while(s[i]!='.') a+=s[i],i++;
    i++;
    while(i!=s.size()) b+=s[i],i++;

}
string decode1(string s) {
    string res="";
    int a = stoi(s);
    rep(i,8) {
        if(a&1) res+="1";
        else res+="0";
        a>>=1;
    }
    if(a!=0) flag=false;
    reverse(all(res));
    return res;
}

string decode2(string s) {
    string res="";
    int a = stoi(s);
    while(a<1000) a*=10;
    // cout<<a<<endl;
    double b = a / 10000.0;

    rep(i,4) {
        b*=2;
        // cout<<b<<endl;
        if(b>0) res += "1",b-=1;
        else res+="0";
    }
    if(b != 0.0) flag=false;

    return res;
}
void solve() {
    flag=true;
    string a,b;
    split(n,a,b);
    string ans = decode1(a)+"."+decode2(b);
    if(flag) {
        cout<<ans<<endl;
    }
    else {
        cout<<"NA"<<endl;
    }

}
int main() {
    while(cin>>n) {
        if(n=="-1.0") break;
        solve();
    }
    return 0;
}

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

int main() {
	int a, b;
	char c;
	while(cin >> a >> c >> b, !(a == -1 && b == 0)) {
		int s = 1;
		if(a < 0) {
			s = -1;
			a *= s;
		}
		while(b != 0 && b < 1000)
			b *= 10;
		a *= 16; b *= 16;
		a += b / 10000;

		if((~(0xfff) & a) || (b % 10000))
			cout << "NA" << endl;
		else {
			if(s < 0)
				cout << "-";
			for(int i = 0; i < 12; i++) {
				if(i == 8) cout << ".";
				cout << !!(a & (0x1 << (11-i)));
			}cout << endl;
		}
	}
}

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

int main() {
	while (1) {
		double n;
		cin >> n;
		if (n < 0)
			break;

		int in = (int)n;
		double dou;
		for (dou = n; dou >= 1; dou--);

		double ans=0;
		for (int i = 0; i < 8; i++) {
			ans += (in % 2)*pow(10, i);
			in /= 2;

			
			if (i < 4) {
				int doub = dou * 2;
				ans += doub * pow(10, -i - 1);
				if (doub == 1)
					dou = dou * 2 - 1;
				else
					dou *= 2;
			}
		}
		if (in > 0 || dou != 0)
			cout << "NA" << endl;
		else {
			for (int i = 0;; i++) {
				if (ans - pow(10, i) < pow(10, i)) {
					for (int j = 0; j < 7 - i; j++)
						cout << 0;
					break;
				}
			}
			cout << fixed;
			cout << setprecision(4) << ans << endl;
		}
	}
	return 0;
}