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<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=4096;
		//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>=4096){
			printf("NA\n");
			h=1;
			//printf("1111\n");
		}
		if(d[12]!=1&&d[12]!=0&&h==0){
			printf("NA\n");
			h=1;
		}
		if((a*16)-s>0&&h==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=1;i<=12;i++){
				printf("%d",d[i]);
				if(i==8){
					printf(".");
				}
			}
			printf("\n");
		}
	}
	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  double num;
  while (true) {
    cin >> num;
    if (num < 0)
      break;

    int a = num;
    double b = num - a;
    string s;
    while (a != 0) {
      if (a % 2 != 0)
        s = '1' + s;
      else
        s = '0' + s;
      a /= 2;
    }

    if (s.size() > 8) {
      cout << "NA" << endl;
      continue;
    }
    s += '.';
    while (s.size() < 9)
      s = '0' + s;

    double hoge = 1.0 / 2;
    while (b != 0) {
      if (b >= hoge)
        s += '1';
      else
        s += '0';
      b -= hoge;
      hoge /= 2;
      if (s.size() > 13)
        break;
    }

    if (s.size() > 13) {
      cout << "NA" << endl;
      continue;
    }
    while (s.size() < 13)
      s += '0';
    cout << s << endl;
  }
  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){
        string input;
        cin >> input;
        if(input[0]=='-')break;

        int dot_i;
        for(int i=0;i<input.size();i++){
            if(input[i]=='.'){
                dot_i = i;
                break;
            }
        }

        int p=1, a=0, b=0;
        for(int i=dot_i-1;i>=0;i--){
            a += (input[i]-'0') * p;
            p *= 10;
        }
        p = 1000;
        for(int i=dot_i+1;i<input.size();i++){
            b += (input[i]-'0') * p;
            p /= 10;
        }

        string a_str = "00000000", b_str = "0000";
        for(int i=0;i<8&&a>0;i++){
            a_str[7-i] += a&1;
            a >>= 1;
        }
        p = 5000;
        for(int i=0;i<4;i++){
            b_str[i] += b / p;
            b %= p;
            p /= 2;
        }

        if (a>0||b>0){
            cout << "NA" << endl;
        }else{
            cout << a_str << "." << b_str << endl;
        }
    }

    return 0;
}

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++: // AOJ 0220
#include<cstdio>
#include<string>

int main()
{
	double f;
	while( scanf( "%lf", &f ), f >= 0 )
	{
		int a = f;
		std::string s, t;
		bool fl = true;

		while( a > 0 )
		{
			if( s.size() >= 8 ) { fl = false; break; }
			s += (a&1)+'0';
			a >>= 1;
		}
		if( fl )
		{
			int cnt = 0;
			f -= int(f);
			while( f )
			{
				if( cnt >= 4 ) { fl = false; break; }
				f *= 2;
				t += int(f) ? '1' : '0';
				f -= int(f);
				++cnt;
			}
		}

		if( fl )
		{
			printf( "%s", std::string( 8-s.size(), '0' ).c_str() );
			for( int i = s.size()-1; i >= 0; --i )
				printf( "%c", s[i] );
			putchar( '.' );
			printf( "%s", t.c_str() );
			printf( "%s\n", std::string( 4-t.size(), '0' ).c_str() );
		}
		else
			puts( "NA" );
	}

	return 0;
}

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

double pwd( int tei,int n ){
	int i;
	double ans = 1;
	if( n >= 0 ){	
		for( i = 0;i < n;i++ ){
			ans *= tei;
		}
	}
	else{
		for(i = 0;i < -n;i++ ){
			ans /= tei;
		}
	}
	return ans;
}

int main(){
	double n;
	int ans[12];

	while( cin >> n ){
		if( n < 0 )
			break;
		for(int i = 7; i >= -4; i--)
		{
			if( n >= pwd( 2,i ) ){
				ans[i+4] = 1;
				n -= pwd( 2,i );
			}
			else{
				ans[i+4] = 0;
			}
		}
		if( n != 0 ){
			cout << "NA" << endl;
			continue;
		}
		for( int i = 11;i >= 0;i-- ){
			cout << ans[i];
			if( i == 4 ){
				cout << ".";
			}
			if( i == 0){
				cout << endl;
			}
		}
			
	}
	return 0;
}

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

void slove(int a, double b){
	int n=128;
	vector<int> b1, b2;
	for(int i=0; i<8; i++){
		if(a/n != 0){
			b1.push_back(1);
			a-=n;
		}
		else {
			b1.push_back(0);
		}
		n/=2;
	}
	
	for(int i=0; i<4; i++){
		b=b*2.0;
		if(b >= 1.0){
			b2.push_back(1);
			b-=1.0;
		}
		else b2.push_back(0);
	}
	
	if(b!=0) cout << "NA";
	else{
		vector<int>::iterator it = b1.begin();
		while(it != b1.end()){
			cout << *it;
			it++;
		}
		
		cout << '.';
		
		vector<int>::iterator it2 = b2.begin();
		while(it2 != b2.end()){
			cout << *it2;
			it2++;
		}
		
	}
	cout << endl;
}

int main(){
	int a;
	double n, b;
	
	while(cin >>n){
		if(n<0) break;
		a=(int)n;   // À
		b=n-(int)n; // ¬_
		slove(a,b);
	}
}

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

int main() {
	int a, b;
	char c;
	while(cin >> a >> c >> b, a >= 0) {
		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>

using namespace std;

int A[8];
int B[4];

int main(int argc, char** argv)
{
	int a, c;
	double b;
	double d;
	
	while( 1 )
	{
		cin >> d;
		if(d < 0.0) break;
		
		a = (int)d;
		b = d - a;
		
		for(int i=7; i>=0; i--)
		{
			A[i] = a%2;
			a /= 2;
		}
		
		for(int i=0; i<4; i++)
		{
			b *= 2.0;
			if(b>=1.0) B[i] = 1, b-=1.0;
			else B[i] = 0;
		}
		
		if(a==0 && b==0.0)
		{
			for(int i=0; i<8; i++) cout << A[i];
			for(int i=0; i<4; i++) cout << B[i];
			cout << endl;
		}
		else cout << "NA" << endl;
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	double n;
	while(true){
		cin>>n;
		if(n<0.0)break;
		bool na=false;
		if(n>128.0)na=true;
		int x=n/(0.25*0.25);
		if(x*(0.25*0.25)!=n)na=true;
		if(na==true)
			cout<<"NA"<<endl;
		else{
		int bit=n*16;
		int ans[12];
		for(int j=0;j<12;j++)
			ans[j]=(bit>>j)&1;
		for(int j=11;j>=0;j--){
			cout<<ans[j];
			if(j==4)cout<<".";
		}
		cout<<endl;
		}
	}
	return 0;
}