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;

int a[8] = {128,64,32,16,8,4,2,1};

int main() {

    while(1){

        double d;

        cin >> d;

        if(d < 0.0){
            break;
        }

        if(d>256){
            printf("NA\n");
            continue;
        }

        int r = (int)d;

        double few = d-(double)r;

        string sfew;


        if(few == 0.0){
            sfew = "0000";
        }
        else if(few == 0.5){
            sfew = "1000";
        }
        else if(few == 0.25){
            sfew = "0100";
        }
        else if(few == 0.125){
            sfew = "0010";
        }
        else if(few == 0.0625){
            sfew = "0001";
        }
        else if(few == 0.1875){
            sfew = "0011";
        }
        else if(few == 0.3125){
            sfew = "0101";
        }
        else if(few == 0.5625){
            sfew = "1001";
        }
        else if(few == 0.375){
            sfew = "0110";
        }
        else if(few == 0.625){
            sfew = "1010";
        }
        else if(few == 0.75){
            sfew = "1100";
        }
        else if(few == 0.4375){
            sfew = "0111";
        }
        else if(few == 0.6875){
            sfew = "1011";
        }
        else if(few == 0.8125){
            sfew = "1101";
        }
        else if(few == 0.875){
            sfew = "1110";
        }
        else if(few == 0.9375){
            sfew = "1111";
        }
        else{
            printf("NA\n");
            continue;
        }

        sfew = "." + sfew;

        string sr;

        for(int i=0;i<8;i++){
            if(r>=a[i]){
                r -= a[i];
                sr += "1";
            }
            else{
                sr += "0";
            }
        }

        cout << sr << sfew << endl;





    }

    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
int main(){
	double n;
	ios::sync_with_stdio(false);
		//for(int i=0;i<ans.size();i++)cout<<ans[i]<<" ";cout<<endl;
	while(cin>>n){
	if(n<0)break;
	vector<bool>ans(0);
	queue< vector<bool> >bfs;
	bfs.push(ans);
	while(!bfs.empty()){
		vector<bool>tmp=bfs.front();
		bfs.pop();
		if(tmp.size()>12){
		cout<<"NA"<<endl;
		break;
		}
		double sum=0;
		for(int i=0;i<min(8,(int)tmp.size());i++)if(tmp[i])sum+=pow(2,7-i);
		for(int i=0;i<min(4,(int)tmp.size()-5);i++)if(tmp[8+i])sum+=pow(2,-1*(i+1));
		if(sum==n){
		int cnt=0;
		for(int i=0;i<tmp.size();i++){
		cout<<tmp[i];
		if(cnt==7)cout<<'.';
		cnt++;
		}
		for(int i=0;i<12-tmp.size();i++){
		cout<<'0';
		if(cnt==7)cout<<'.';
		cnt++;
		}
		cout<<endl;
		break;
		}
		tmp.push_back(0);
		bfs.push(tmp);
		tmp.erase(tmp.begin()+(tmp.size()-1));
		tmp.push_back(1);
		bfs.push(tmp);
	}
	}

C++: #include<iostream>
using namespace std;
int main(){
	while(1){
		char se[]={"00000000"};
		char so[]={"0000"};
		float n;
		cin>>n;
		if(n==-1.0)break;
		int s=(int)n;
		double x=(double)s;
		n-=x;
		//cout<<n<<endl<<s<<endl<<x<<endl;
		int i=0,a,flag=0;
		while(1){
			if(i>7&&s>=2){
				flag=1;
				break;
			}
			a=s%2;
			if(a==1){
				se[i]='1';
			}
			s/=2;
			i++;
			if(s<2){
				if(i<=7){
					if(s==1){
						se[i]='1';
					}
					
				}
				else{
					flag=1;
				}
				break;
			}
		}
		if(flag==1){
			cout<<"NA"<<endl;
			continue;
		}
		int j=0;
		double b;
		 flag=0;
		while(1){
			if(j>=4&&b!=0.0){
				flag=1;
				break;
			}
			b=n*2;
			if(b>=1.0){
				b-=1.0;
				so[j]='1';
				if(b==0.0){
					j++;
					break;
				}
			}
			j++;	
		}
		if(flag==1){
			cout<<"NA"<<endl;
			continue;
		}
		for(int q=7;q>=0;q--){
			cout<<se[q];
		}
		cout<<'.';
		for(int p=0;p<=3;p++){
			cout<<so[p];
		}
		cout<<endl;
	}
}

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

int main()
{
    double n, div;
    char a;
    string str;
    while( cin >> n )
    {
        if( n < 0 )
            break;
        
        str = "";
        div = 128;

        for( int i = 0; i < 12; i++ )
        {
            if( i == 8 )
                str += '.';
            a = (int)( n / div ) + '0';
            str += a;
            if( a == '1' )
                n -= div;
            div /= 2;
        }
        if( n != 0 )
            cout << "NA" << endl;
        else
            cout << str << endl;
    }
    
    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#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 it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  float n;
  float array[] = { 256,128,64,32,16,8,4,2,1,0.5,0.25,0.125,0.0625 };
  while(cin>>n,n>0){
    string s = "";
    for(int i = 0 ; i < 13 ; i ++){
      if(i == 9)s += '.';
    if(n>=array[i]){
      n -= array[i]; 
      s += "1";
    }else{
      s += "0";
    }
   }
   if(n==0)cout<<s<<endl;
   else cout<<"NA"<<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){
        double n;
        scanf("%lf",&n);
        if(n<0)break;
        int a = (int)(n * 16);
        if(a>=(1<<12) || a=<(n*16)){
            cout << "NA" << endl;
        }else{
            for(int i=11;i>=0;i--){
                if(i==3) cout << ".";
                cout << ((a>>i)&1);
            }
            cout << endl;
        }
    }

    return 0;
}