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;


void solve()
{
	double a[16];
	for(int i = 0; i < 16; ++i)
	{
		a[i] = i / 16.0;
	}
	double n;
	while(cin >> n, n >= 0)
	{
		char c[13];
		bool flag =true;
		for(int i = 0; i < 16; ++i)
		{
			if(n - (int)n == a[i])
			{
				flag = false;
				for(int j = 12; j >= 9; --j)
				{
					c[j] = i % 2 + '0';
					i /= 2;
				}
				break;
			}
		}
		if(flag)
		{
			cout << "NA" << endl;
		}
		else
		{
			c[8] = '.';
			int num = n;
			for(int i = 7; i >= 0; --i)
			{
				c[i] = num % 2 + '0';
				num /= 2;
			}
			for(int i = 0; i < 13; ++i)
			{
				cout << c[i];
			}
			cout << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;


int main(void){
	string n;
	while(cin >> n){
		if(n[0]=='-') break;
		int i=0,cnt=0;
		rep(j,n.size()){
			if(n[j]=='.'){
				cnt=0;
			}else{
				i=10*i+n[j]-'0';
				cnt++;
			}
		}
		bool ok=true;
		rep(j,cnt){
			if(i%5) ok=false;
			i/=5;
		}
		rep(j,4-cnt) i*=2;
		if(i>=4096) ok=false;
		if(ok){
			for(int j=11;j>=4;--j){
				cout << ((i&(1<<j))>0);
			}
			putchar('.');
			for(int j=3;j>=0;--j){
				cout << ((i&(1<<j))>0);
			}
			puts("");
		}else{
			puts("NG");
		}
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#define rep(i,n) for(int i=0;i<(int)n;i++)

using namespace std;


int main()
{
	double a;
	for(cin>>a;a>=0.0;cin>>a)
	{
		int j;
		double k;
		string ans,ans2;
		j=a;
		k=a-j;
		while(j!=0)
		{
			ans+=j%2==1?"1":"0";
			j/=2;
		}
		if(ans.size()>8)
		{
			cout<<"NA"<<endl;
			continue;
		}
		else
		{
			while(ans.size()!=8)ans+="0";
		}
		reverse(ans.begin(),ans.end());
		ans+=".";
		
		
		
		
		int i=1;
		while(k>=0.0000000000001)
		{
			if(k>=(1.0/2.0)/i)
			{
				k=k-(1.0/2.0)/i;
				ans2+="1";
			}
			else
			{
				ans2+="0";
			}
			i++;
			if(ans2.size()>=6)break;
		}
		
		if(ans2.size()>=5)
		{
			cout<<"NA"<<endl;
			continue;
		}
		else
		{
			while(ans2.size()!=4)ans2+="0";
		}
		
		cout<<ans<<ans2<<endl;
		
		
	}
}

C++: #include<iostream>
#include<stack>
#include<queue>
using namespace std;
int main(){
	double n,j;
	int i,count;
	bool flag = true;
	stack<int> s;
	queue<int> q;
	while(cin >> n){
		if(n < 0) return 0;
		count = 0;
		i = n; j = n-i;
		while(i > 3 && count <= 8){
			s.push(i%2);
			i/=2;
			count++;
		}
		if(count > 8)
			flag = false;
		s.push(i%2);
		s.push(i/2);
		count += 2;
		for(int x=count; x<8; x++)
			s.push(0);
		count=0;
		
		while( j != 1.0  && count <= 4){
			q.push(j*2);
			j *= 2;
			if(j > 1)
				j -= 1;
			count++;
		}
		if(count > 4)
			flag=false;
		for(int x=count; x<4; x++)
			q.push(0);

		if(flag == true){
			int size=s.size(), size1=q.size();
			for(int x=0; x<size; x++){
				cout << s.top();
				s.pop();
			}
			cout << ".";
			for(int x=0; x<size1; x++){
				cout << q.front();
				q.pop();
			}
		}
		else{
			cout << "NA";
		}
		
		cout << endl;
	}

	return 0;
}

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

int main() {
	long long a, b;
	char c;
	while(cin >> a >> c >> b, a >= 0) {
		if(c != '.')
			abort();
		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 <vector>
#include <sstream>
#include <cstdio>
using namespace std;

int toInt(const string &s){
  stringstream ss;
  ss<<s;
  int a;
  ss>>a;
  return a;
}

int main(void){
  string s;
  while(cin>>s){
    string p,q;
    if(s.find('.')!=-1){p=s.substr(0,s.find('.'));q=s.substr(s.find('.')+1,s.size()-s.find('.'));}
    else p=s;
    while(q.size()<4)q+='0';
    int pp=toInt(p),qq=toInt(q);if(pp<0)break;
    vector<int> a,b;
    for(int i=0;i<4;++i){
      b.push_back((qq*2/10000)?1:0);
      qq=(qq*2)%10000;
    }
    if(qq)cout<<"NA"<<endl;
    else{
      for(int i=0,t=1<<7;i<8;++i){
        a.push_back((pp/t)?1:0);
        pp%=t;
        t/=2;
      }
      for(int i=0;i<8;++i)cout<<a[i];
      cout<<".";
      for(int i=0;i<4;++i)cout<<b[i];
      cout<<endl;
    }
  }
  return 0;
}

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

int main()
{
    string S;
    while ( cin >> S, S[0] != '-' ) {
        string T;
        int num = 0, pos;
        if ( (pos = S.find('.')) != (int)string::npos ) {
            num = S.size() - pos - 1;
        }
        for ( int i = 0; i < S.size(); i++ ) {
            if ( S[i] != '.' ) {
                T += S[i];
            }
        }

        int val = atoi(T.c_str()) * 16;
        bool flag = true;
        int g = 1;
        for ( int i = 0; i < num; i++ ) {
            if ( (val % (g * 10)) != 0 ) {
                flag = false;
            }
            g *= 10;
        }
        if ( val >= g * 4096 ) {
            flag = false;
        }
        if ( flag ) {
            val /= g;
            string ans;
            for ( int i = 0; i < 4; i++ ) {
                ans += (char)(((val & (1 << i)) >> i) + '0');
            }
            ans += '.';
            for ( int i = 4; i < 12; i++ ) {
                ans += (char)(((val & (1 << i)) >> i) + '0');
            }
            reverse(ans.begin(), ans.end());
            cout << ans << endl;
        } else {
            cout << "NA" << endl;
        }
    }
    return ( 0 );
}