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>

using namespace std;

int main(void){
  double in;
  while(cin>>in,in!=-1){
    if(in>128){cout<<"NA";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<0?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;
  }
}

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]!='.'&&i<s.size()) {
        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) {
    if(s=="") return "0000";
    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 <bits/stdc++.h>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define X real()
#define Y imag()
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using comd = complex<double>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

  template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double n,f;
  int r;
  while(cin >> n){
    if(n < 0) break;
    string s = "",s2 = "";
    r = int(n);
    f = n - int(n);
    rep(i,8){
      if(r & (1 << i)){
        s += "1";
      }
      else{
        s += "0";
      }
    }
    rep(i,4){
      f *= 2;
      if(f >= 1){
        f-=1;
        s2+="1";
      }
      else{
        s2+="0";
      }
    }
    bool t = true;
    if( f > 0){
      t = false;
    }
    if( r < (1 << 9) && t){
      reverse(all(s));
      cout << s+"."+s2 << endl;
    }
    else cout << "NA" << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
int de[8] = {128,62,32,16,8,4,2,1};
double dou[4] = {0.5,0.25,0.125,0.0625};

using namespace std;

int main(void){
  double in;
  while(cin>>in,in>0){
    vector<int> ans(12,0);
    bool used = false;
    for(int i = 0 ; i < 8 ; i ++){
      if(in>de[i]){
          ans[i] = 1;
          in -= de[i];
          used = true;
         
      }
    }
    for(int i = 0 ; i < 4 ; i ++){
      if(in>dou[i]){
          ans[i+8] = 1;
          in -= dou[i];
          used = true;
      }
    }
    if(used && in == 0){
      for(int i = 0 ; i < 8 ; i ++)
        cout<<ans[i];
      cout<<".";
      for(int i = 8 ; i < 12 ; i ++)
        cout<<ans[i];
      cout<<endl;
    }else 
      cout<<"NA"<<endl;
    
    
  }
}

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

using namespace std;

typedef long long BigInt;
int main() {
  double n;
  while (true) {
    cin >> n;
    if (n < 0) {
      return 0;
    }
    if ((n * 16) - BigInt(n * 16) == 0 and n < (1 << 8)) {
      for (int i = 0; i < 8; ++i) {
        cout << ((BigInt(n) & (1 << (7 - i))) > 0? 1: 0);
      }
      cout << ".";
      for (int i = 0; i < 4; ++i) {
        cout << ((BigInt(n * (2 << i)) & 1) > 0? 1: 0);
      }
      cout << endl;
    } else {
      cout << "NA" << endl;
    }
  }
}

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

int main() {
    double d;
    while (cin >> d, d >= 0.0000000) {
        int n = floor(d);
        if (n >= 1 << 8) {
            cout << "NA" << endl;
            continue;
        }

        string str;
        while (n) {
            str = (n % 2 == 0 ? "0" : "1") + str;
            n /= 2;
        }
        while (str.size() < 8) str = "0" + str;
        str += ".";

        double s = d - (double)floor(d);
        double v[] = {0.5, 0.25, 0.125, 0.0625};
        for (int i = 0; i < 4; i++) {
            if (s >= v[i]) {
                s -= v[i];
                str += "1";
            } else {
                str += "0";
            }
        }
        if (s) {
            cout << "NA" << endl;
        } else {
            cout << str << endl;
        }
    }

    return 0;
}