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;

bool zero(double f){
	return fabs(f) < 0.0000001;
}

int main(){
	double n;
	while(scanf("%lf",&n), n >= 0.0){
		int r = (int)n;
		double f = ((n-r) * 16);
		
		if(r >= (1<<8)){
			printf("NA\n");
			continue;
		}
		if(!zero(f-(int)f)){
			printf("NA\n");
			continue;
		}
		for(int i = 7; i >= 0; i--){
			printf("%d",r / (1<<i));
			r %= (1<<i);
		}
		printf(".");
		int fr = (int)f;
		for(int i = 3; i >= 0; i--){
			printf("%d",fr / (1<<i));
			fr %= (1<<i);
		}
		printf("\n");
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
	double num;
	while(cin>>num,num>=0){
	    string str;
		for(int i=7;i>-5;i--){
			str+=int(num/pow(2,i))+'0';
			if(num/pow(2,i)>=1)num-=pow(2,i);
			if(i==0)str+='.';
		}
		if(num/pow(2,-5)>0||num/pow(2,9)>=1)cout<<"NA"<<endl;
		else cout<<str<<endl;
	}
}

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

using namespace std;

int main()
{
    double N;
    while(cin >> N, N >= 0)
    {
        int n = N * 16 + 1e-8;
        if (abs(N * 16 - (int)(N * 16)) > 1e-8 || n >= (1 << 12))
        {
            puts("NA");
            continue;
        }
        for (int i = 11; i >= 0; i--)
        {
            printf("%d", (n >> i) & 1);
            if (i == 4) printf(".");
        }
        puts("");
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define EPS 1e-14
int main()
{
	while(true){
		double X;
		cin >> X;
		if(X==-1.0)break;
		int F[12];
		for(int i=0;i<12;i++){
			F[i]=0;
		}
		double now=128;
		for(int i=0;i<12;i++){
			if(X>=now-EPS){
				F[i]=1;
				X-=now;
			}
			now/=2;
			//printf("%.3f %.3f\n",X,now);
		}
		if(X>EPS){
			printf("NA\n");
		}
		else{
			for(int i=0;i<12;i++){
				printf("%d",F[i]);
				if(i==7)printf(".");
			}
			printf("\n");
		}
	}
	return 0;
}

C++: #include<stdio.h>
int main()
{
	int x,c,i,k;
float a,y,z,w,q;
	scanf("%f",&a);
	while(a>=0){
		x=a;
		y=a-x;
		z=0;
		c=0;
		w=0;
		k=0;
		k=0;
		if(x>=128){
			z=z+10000000;
			x=x-128;
			k++;
		}
		if(x>=64){
			z=z+1000000;
			x=x-64;
			if(k==0)
			c=1;
			k++;
		}
		if(x>=32){
			z=z+100000;
			x=x-32;
			if(k==0)
			c=2;
			k++;
		}
		if(x>=16){
			z=z+10000;
			x=x-16;
			if(k==0)
			c=3;
			k++;
		}
		if(x>=8){
			z=z+1000;
			x=x-8;
			if(k==0)
			c=4;
			k++;
		}
		if(x>=4){
			z=z+100;
			x=x-4;
			if(k==0)
			c=5;
			k++;
		}
		if(x>=2){
			z=z+10;
			x=x-2;
			if(k==0)
			c=6;
			k++;
		}
		if(x>=1){
			z=z+1;
			x=x-1;
			if(k==0)
			c=7;
			k++;
		}
		
		if(y>=0.5){
			w=w+0.1;
			y=y-0.5;
		}
		if(y>=0.25){
			w=w+0.01;
			y=y-0.25;
		}
		if(y>=0.125){
			w=w+0.001;
			y=y-0.125;
		}
		if(y>=0.0625){
			w=w+0.0001;
			y=y-0.0625;
		}
		
		if(x==0&&y==0){
			for(i=0;i<c;i++){
				printf("0");
			}
		printf("%.4f\n",z+w);
		}
		else{
			printf("NA\n");
		}
	scanf("%f",&a);
	}
	return 0;
}

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;
}

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

using namespace std;

int main(){
	
	string in;
	string ls,rs;
	string ans;
	int li,ri;
	bool f;
	int sdata[8];
	int fdata[4]={5000,2500,1250,625};

	for(int i=0;i<8;i++){
		sdata[i]=pow(2,i);
	}

	while(1){
		cin>>in;
		if(in[0]=='-') break;

		ls="",rs="";
		f=false;
		for(int i=0;i<in.size();i++){
			if(in[i]=='.') f=true;
			else if(f){
				rs+=in[i];
			}
			else{
				ls+=in[i];
			}
		}

		li=0;
		for(int i=0;i<ls.size();i++){
			li+=(ls[ls.size()-1-i]-'0')*pow(10,i);
		}

		ri=0;
		for(int i=0;i<rs.size();i++){
			ri+=(rs[rs.size()-1-i]-'0')*pow(10,i);
		}
		while(ri<1000) ri*=10;
		ans="";
		for(int i=7;i>=0;i--){
			if(li>=sdata[i]){
				li-=sdata[i];
				ans+="1";
			}
			else ans+="0";
		}
		if(li!=0){
			cout<<"NA"<<endl;
			continue;
		}
		ans+=".";

		for(int i=0;i<4;i++){
			if(ri>=fdata[i]){
				ri-=fdata[i];
				ans+="1";
			}
			else ans+="0";
		}
		if(ri!=0){
			cout<<"NA"<<endl;
			continue;
		}
		cout<<ans<<endl;
	}

}

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

int main() {
	float f;
	while (cin >> f && f >= 0.0) {
		bool n[12];
		int j = 0;
		for (int i = 7; i >= -4; --i, ++j) {
			if (f >= pow(2, i)) {
				n[j] = true;
				f -= (float)pow(2, i);
			}
			else {
				n[j] = false;
			}
		}
		if (f == 0) {
			for (int i = 0; i < 12; ++i) {
				if (n[i]) { cout << '1'; }
				else { cout << '0'; }
				if (i == 7) { cout << '.'; }
				if (i == 11) { cout << endl; }
			}
		}
		else {
			cout << "NA" << endl;
		}
	}

	return 0;
}

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

string Z(int m){
    if(m>=(1<<8))return "";
    string ret;
    for(int i=7;i>=0;i--){
        if((m>>i)&1)ret+="1";
        else ret+="0";
    }
    return ret;
}

string R(double r){
    double table[]={1.0/2,1.0/4,1.0/8,1.0/16};
    string ret;
    for(int i=0;i<4;i++){
        if(r>=table[i]){
            r-=table[i];
            ret+="1";
        }
        else ret+="0";
    }
    if(r!=0)return "";
    return ret;
}


int main(){

    double n;
    while(cin>>n,n!=-1){
        int m=(int)n;
        double r=n-m;

        if(Z(m)!=""&&R(r)!=""){
            cout<<Z(m)+"."+R(r)<<endl;
        }
        else cout<<"NA"<<endl;
    }
    return 0;
}

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

int main()
{
    string s;
    while(true) {
        cin >> s;
        if(s.size() <= 0 || s[0] == '-')
            break;
        
        int a, b;
        a = 0;
        for(int i = 0; i < s.find('.'); i++) 
            a = a * 10 + s[i] - '0';

        b = 0;
        for(int i = 0; i < 4; i++) {
            if(i + s.find('.') + 1 < s.size()) {
                b = b * 10 + s[i + s.find('.') + 1] - '0';
            } else {
                b *= 10;
            }
        }
        
        string sa, sb;
        //int s,m;
        int n, m;
        sa = "00000000";
        n = m = a;
        for(int i = 7; i >= 0; i--) {
            m = n % 2;
            n /= 2;
            sa[i] += m;
        }

        sb = "0000";        
        n = b;
        for(int i = 0; i < 4; i++) {
            n *= 2;
            sb[i] += n / 10000;
            n %= 10000;
        }

        if(a > 255 || n != 0) 
            cout << "NA" << endl;
        else 
            cout << sa << "." << sb << endl;
            
    }
}