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>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  int n,m;
  while(scanf("%d.%d",&n,&m), n >= 0){
    string ans;

    if( n > 255 ) ans = "NA";
    else{
      REP(i,8){
	if(n & (1 << i))
	  ans = "1" + ans;
	else
	  ans = "0" + ans;
      }

      ans += ".";
      while(m*10 < 10000) m *= 10;

      REP(i,4){
	m *= 2;
	if( m >= 10000 ){
	  ans = ans + "1";
	  m -= 10000;
	}else{
	  ans = ans + "0";
	}
      }
      if( m != 0 ) ans = "NA";

      cout << ans << endl;
    }
  }
  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)cout<<"NA"<<endl;
		else cout<<str<<endl;
	}
}

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

double to_f(const string &s) {
    istringstream is(s);
    double d;
    is >> d;
    return d;
}

string binary(int n, int p) {
    string s;
    int r = 1<<(p-1);
    while (r != 0) {
        if (n / r) {
            s.push_back('1');
        } else {
            s.push_back('0');
        }
        n %= r;
        r >>= 1;
    }
    return s;
}

int main() {
    string s;
    while (cin >> s) {
        if (s[0] == '-') break;
        int n; double d;
        n = (int)to_f(s);
        d = to_f(s) - n;
//        cout << n << ' ' << d << endl;

        if (0 <= n && n < (1<<8) && d*16 == (int)(d*16)) {
            cout << binary(n, 8) << '.' << binary(d*16, 4) << endl;
        } else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

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

int main(){
	double n;
	int nn,a[16];
	while(1){
		cin >> n;
		if(n < 0.0) break;
		if(n > 256.0) {
			cout << "NA" << endl;
			continue;
		}
		nn = (int)round(n * 16.0);
		//printf("%d %lf",nn,n);
		if(abs((double)nn - n * 16.0) > 0.00001) {
			cout << "NA" << endl;
			continue;
		}
		for(int i = 15;i >= 0;i--){
			a[i] = nn % 2;
			nn /= 2;
		}
		for(int i = 0;i < 16;i++){
			cout << a[i];
			if(i == 11) cout << ".";
		}
		cout << endl;
	}
	return 0;
}

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

#define DBG(x) cerr << #x << " = " << x << endl

template <class T, class U> 
T lexical_cast(const U& from) {
  stringstream ss;
  ss << from;
  T to;
  ss >> to;
  return to;
}

int main() {
  while(true) {
    string s; cin >> s;
    if(s[0] == '-') break;
    string ax, bx;
    for(int i = 0; i < (int)s.size(); ++i) {
      if(s[i] == '.') {
        ax = s.substr(0, i);
        bx= "0." + s.substr(i + 1);
      }
    }
    if(ax == "") {
      ax = s;
      bx = "0.0";
    }

    int a = lexical_cast<int>(ax);
    double b = lexical_cast<double>(bx);
    string as, bs;
    while(a > 0 && as.size() <= 8) {
      as.push_back('0' + a % 2);
      a /= 2;
    }
    reverse(as.begin(), as.end());
    while(abs(b) > 1e-8 && bs.size() <= 4) {
      bs.push_back('0' + (int)(b * 2));
      b *= 2;
      if(b >= 1.0) b -= 1.0;
    }
    if(as.size() <= 8 && bs.size() <= 4) {
      for(int i = 0; i < 8 - (int)as.size(); ++i) cout << "0";
      cout << as << "." << bs;
      for(int i = 0; i < 4 - (int)bs.size(); ++i) cout << "0";
      cout << endl;
    }
    else {
      cout << "NA" << endl;
    }
  }
}

C++: #include<stdio.h>
int main(void)
{
    int a[12],i,s[8]={128,64,32,16,8,4,2,1};
	float n;
	while(1){
	    scanf("%f",&n);
		if(n<0) break;
		for(i=0;i<12;i++) a[i]=0;
		for(i=0;i<8;i++){
		    if(n>=s[i]){
			    n-=s[i];
				a[i]=1;
			}
		}
		if(n>=0.5){
		    n-=0.5;
			a[8]=1;
		}
		if(n>=0.25){
		    n-=0.25;
			a[9]=1;
		}
		if(n>=0.125){
		    n-=0.125;
			a[10]=1;
		}
		if(n>=0.0625){
		    n-=0.0625;
			a[11]=1;
		}
		if(n==0){
		    for(i=0;i<12;i++){
			    printf("%d",a[i]);
				if(i==7) printf(".");
			}
		}
		else if(n!=0) printf("NA\n");
	}
	return 0;
}

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

int main(){
	float f;
	while( std::cin>>f, f>=0){
		int i=f;
		f=f-i;
		if( i>255 ){std::cout<<"NA"<<std::endl;continue;}
		int Fnum=(1<<4)*f;
		if( Fnum != (1<<4)*f ){std::cout<<"NA"<<std::endl;continue;}
		int count=8;
		std::cout<<Fnum<<std::endl;
		while( count-- ){
			std::cout<<((i&(1<<count))==0?'0':'1');
		}
		std::cout<<'.';
		count=4;
		while( count-- ){
			std::cout<<((Fnum&(1<<count))==0?'0':'1');
		}
		std::cout<<std::endl;
	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	float a;
	int s,d[13],f,g,h=0,i,j,z;
	while(1){
		scanf("%f",&a);
		z=a;
		if(z<0){
			break;
		}
		for(i=1;i<=12;i++){
			d[i]=0;
		}
		//printf("%f",a);
		f=a*16;
		i=2048;
		//printf("a == %f\n",a*16);
		s=f;
		j=1;
		while(i!=1){
			i=i/2;
			if(i<=f){
				d[j]=f/i;
				//printf("d[%d] = %d %d %d\n",j,d[j],i,f);
				f=f-i;
			}
			j++;
		}
		if(a>=2024){
			printf("NA\n");
			h=1;
			//printf("1111\n");
		}
		if((a*16)-s>0){
			//printf("2222 = %d\n",a*16-s);
			printf("NA\n");
			h=1;
		}
		/*for(i=0;i<12;i++){
			printf("%d\n",d[i]);
		}*/
		if(h==0){
			for(i=0;i<12;i++){
				printf("%d",d[i]);
				if(i==7){
					printf(".");
				}
			}
			printf("\n");
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <cmath>

using namespace std;

int main()
{
	for(char buf[1024];fgets(buf,1024,stdin),buf[0]!='-';){
		double x; sscanf(buf,"%lf",&x);
		
		if(x>=256){
			puts("NA");
			continue;
		}
		if(fmod(x,0.0625)>0){
			puts("NA");
			continue;
		}
		
		int a=x,b=int(x*16)%16;
		for(int i=0;i<8;i++)
			putchar('0'+(a>>7-i&1));
		putchar('.');
		for(int i=0;i<4;i++)
			putchar('0'+(b>>3-i&1));
		putchar('\n');
	}
	return 0;
}

C++: 
#include<cstdio>

int main(void){
double p,q;
int a;
int res[12];
scanf("%lf",&p);
while(p!=-1){

q=1<<8;
if(p>q){
printf("NA\n");
scanf("%lf",&p);
continue;
}

for(a=0;a<12;a++){
q/=2.0;
if(p>=q){
res[a]=1;
p-=q;
}
else res[a]=0;
}
if(p!=0.0){
printf("NA\n");
scanf("%lf",&p);
continue;
}

for(a=0;a<8;a++){
printf("%d",res[a]);
}
printf(".");
for(a=8;a<12;a++){
printf("%d",res[a]);
}
printf("\n");
scanf("%lf",&p);
}
return 0;
}