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 main() {
	double num;
	while(cin>>num,num>0){
	    string str;
		for(double i=128,a;i>0.03125;i/=2){
			str+=int(a=num/i)+'0';
			if(a>=1)num-=i;
			if(i==1)str+='.';
		}
		if(num>0)cout<<"NA"<<endl;
		else cout<<str<<endl;
	}
}

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",&n), n >= 0){
    string ans;
    char buff[8];

    if(getchar() == '.'){
      scanf("%s",buff);
      sscanf(buff,"%d",&m);
      for(int len = strlen(buff); len < 4; len++)
	m *= 10;
    }
    else m = 0;

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

      ans += ".";

      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 <iostream>
using namespace std;

void convert(int x, int p){
	if( p == 12 ) return;
	convert(x/2, p+1);
	if( p == 3 ) cout << ".";
	cout << x%2;
}

int main(){
	for( double x; cin >> x && x >= 0; ){
		int shift = (int)(x*16);
		if( x == shift/16.0 && shift < 4096 ){
			convert( shift, 0 );
			cout << endl;
		} else {
			cout << "NA" << endl;
		}
	}
	return 0;
}

C++: #include<stdio.h>

int main(){
int b1[9]={},b2[9]={};

int x1,x2;

//double x1,x2=0;
//int y1=0,y2=0;
/*
while(scanf("%lf",&x)!=EOF){
x2=x1*10000;
y2=(int)x1;y2*=10000;
y2=(int)x2-(int)x1*10000;
y1=(int)x1;
if(y1>255||y2>9375||b2)

*/

//while(scanf("%d.%d",&x1,&x2)!=EOF){

while(1){
	scanf("%d.%d",&x1,&x2);if(x1<0||x2==0)break;
x2*=1000;
if(x1>255||x2>9375||x2<625)printf("NA\n");

else {
if(x1>=128){x1=x1-128;b1[0]=1;}
if(x1>=64){x1=x1-64;b1[1]=1;}
if(x1>=32){x1=x1-32;b1[2]=1;}
if(x1>=16){x1=x1-16;b1[3]=1;}
if(x1>=8){x1=x1-8;b1[4]=1;}
if(x1>=4){x1=x1-4;b1[5]=1;}
if(x1>=2){x1=x1-2;b1[6]=1;}
if(x1>=1){x1=x1-1;b1[7]=1;}

if(x2>=5000){x2=x2-5000;b2[0]=1;}
if(x2>=2500){x2=x2-2500;b2[1]=1;}
if(x2>=1250){x2=x2-1250;b2[2]=1;}
if(x2>=625){x2=x2-625;b2[3]=1;}

if(x1==0&&x2==0)
{
for(int i=0;i<8;i++)
printf("%d",b1[i]);

printf(".");

for(int i=0;i<4;i++)
printf("%d",b2[i]);

printf("\n");
for(int i=0;i<9;i++)
{
b1[i]=0;b2[i]=0;
}


}

else printf("NA\n");
}
}
return 0;
}

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

using namespace std;

int main() {
	double d;
	while (cin >> d) {
		if (d < 0.0) {
			break;
		} 
		if (d >= 257.0) {
			cout << "NA" << endl;
		} else {
			int a = d;
			double b = d-a;
			int counter[4] = {0};
			if (b >= 0.5) {
				b -= 0.5;
				counter[0] = 1;
			}
			if (b >= 0.25) {
				b -= 0.25;
				counter[1] = 1;
			}
			if (b >= 0.125) {
				b -= 0.125;
				counter[2] = 1;
			}
			if (b >= 0.0625) {
				b -= 0.0625;
				counter[3] = 1;
			}
			if (b > 0.0) {
				cout << "NA" << endl;
			} else {
				string zo = "01";
				string s = "";
				for (int i = 0; i < 8; i++) {
					s += zo[a%2];
					a/= 2;
				}
				string ss = "";
				for (int i = 7; i >= 0; i--) {
					ss += s[i];
				}
				string dd = "";
				for (int i = 0; i < 4; i++) {
					dd += zo[counter[i]];
				}
				cout << ss << '.' << dd << endl;
			}
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;


void changeBinary( int target ){
	int i;
	char str[20] = {'0'};

	i = 0;
	while( target != 0 ){
		str[i] = target % 2 + '0';
		target /= 2;
		i++;
	}
	if( i == 0 ) cout << "00000000.0000";
	else{
		for( int j = 0;j < 12 - i;j++ ) cout << '0';
		for( int j = 0;j < i;j++ ){
			if( i - j == 4 ) cout << '.';
			cout << str[( i - 1) - j ];
		}
	}
	cout << endl;


}
int main(void)
{
	double n;

	while( cin >> n && n >= 0 ){
		n *= 16.0;

		if( n - (int)n || n >= ( 1 << 12 ) ){
			cout << "NA" << endl;
		} else {
			changeBinary( n );
		}

	}

	return 0;
}

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

double pow(int a){
  double res = 1;
  for (int i = 0; i < a; i++) {
    res /= 2;
  }
  return res;
}

int main(int argc, char *argv[]){
  double d;
  while (std::cin >> d) {
    if(d < 0)break;
    int digit = 7;
    string ans;
    for (int i = digit; i >= 0; i--) {
      if(d >= (1<<i)){
        ans = ans + '1';
        d -= (1<<i);
      }else{
        ans = ans + '0';
      }
    }
    ans = ans + ".";
    for (int i = 1; i <= 4; i++) {
      if(d >= pow(i)){
        ans = ans + '1';
        d -= pow(i);
      }else{
        ans = ans + '0';
      }      
    }
    if(d == 0)std::cout << ans << std::endl;
    else std::cout << "NA" << std::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 <string>

using namespace std;

void solve()
{
	double n;
	while(cin >> n)
	{
		if(n < 0)
		{
			break;
		}
		string str;
		int k = 128;
		for(int i = 0; i < 8; ++i)
		{
			if(n >= k)
			{
				n -= k;
				str += "1";
			}
			else
			{
				str += "0";
			}
			k /= 2;
		}
		str += ".";
		double f = 0.5;
		for(int i = 0; i < 4; ++i)
		{
			if(n >= f)
			{
				n -= f;
				str += "1";
			}
			else
			{
				str += "0";
			}
			f /= 2;
		}
		if(n < 1e-8)
		{
			cout << str << endl;
		}
		else
		{
			cout << "NA" << endl;
		}
	}
}

int main()
{
	solve();
	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;
    
    
  }
}