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 <string>
#include <cmath>
using namespace std;

int main() {
	// your code goes here
	double N;
	
	while(cin >> N && N>=0){
		string s;
		for(int i=0;i<8;i++){
			if(N>=pow(2,7-i)){
				N-=pow(2,7-i);
				s+='1';
			}
			else
				s+='0';
		}
		s+='.';
		for(int i=1;i<=4;i++){
			if(N>=pow(2,-i)){
				N-=pow(2,-i);
				s+='1';
			}
			else
				s+='0';
		}
		if(N==0)
		cout << s << 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)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<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int n;
  string s,t,u;
  while(cin>>s&&s[0]!='-'){
    n=atoi(s.substr(0,s.find(".")).c_str());
    if(n>255){
      cout<<"NA"<<endl;
      continue;
    }
    t=u="0000";
    for(i=1;i<(s.find(".")==string::npos?1:(int)(s.length()-s.find(".")));i++)
      t[i-1]=s[s.find(".")+i];
    if(t[0]>'4'){
      t[0]-=5;
      u[0]++;
    }
    if(t[0]>'1'&&t[1]>'4'){
      t[0]-=2;
      t[1]-=5;
      u[1]++;
    }else if(t[0]>'2'){
      t[0]-=3;
      t[1]+=5;
      u[1]++;
    }
    if(t[0]>'0'&&t[1]>'1'&&t[2]>'4'){
      t[0]-=1;
      t[1]-=2;
      t[2]-=5;
      u[2]++;
    }
    if(t[1]>'5'&&t[2]>'1'&&t[3]>'4'){
      t[1]-=6;
      t[2]-=2;
      t[3]-=5;
      u[3]++;
    }
    if(t!="0000"){
      cout<<"NA"<<endl;
      continue;
    }
    for(i=0;i<8;i++){
      cout<<n/(int)pow(2,7-i);
      n%=(int)pow(2,7-i);
    }
    cout<<"."<<u<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

string compute(int n){
  string ret ="";
  while(n>0){
    if (n%2 == 1)ret+="1";
    else ret+="0";
    n/=2;
  }
  while(ret.size() != 8)ret+="0";
  reverse(ret.begin(),ret.end());
  return ret;
}

string compute2(int m,bool &flag){
  const int aho[4]={5000,2500,1250,625};
  rep(i,(1<<4)){
    int val=0;
    rep(j,4){
      if ( (i&(1<<j)) != 0)val+=aho[j];
    }
    if (val == m){
      string ret="";
      rep(j,4){
	if ( (i&(1<<j)) != 0)ret+="1";
	else ret+="0";
      }
      flag=true;
      return ret;
    }
  }
  flag=false;
  return "";
}

main(){
  int n,m;
  char dummy;
  while(cin>>n>>dummy>>m){
    if (n < 0){
      break;
    }
    m*=1000;
    string a=compute(n);
    bool flag;
    string b = compute2(m,flag);
    if (flag)cout << a <<"." << b << endl;
    else cout << "NA" << endl;
  }
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>
#define EPS 0.000001
using namespace std;

double n;

int I;

double D;

int integer[8];
int decimal[4];


bool judge(double a){
	return (a - (int)a < EPS);
}


int Ifunction(int I,int l)
{
	int i = 7;

	int cnt = 0;

	while (I != 0)
	{
		
		if (cnt>=l)
		{
			return 0;
		}

		integer[i--] = I % 2;

		I = I / 2;

		cnt++;
	}
}

void DIfunction(int I)
{
	int i = 0;

	while (I!=0)
	{
		decimal[i++] = I % 2;

		I = I / 2;
	}
}

int Dfunction(double D)
{
	int i = 1;

	int cnt = 0;

	while (!judge(D))
	{

		if (cnt >= 4)
		{
			return 0;
		}

		D *= 2;

		cnt++;

	}

	return cnt;
}

int main(void)
{
	while (cin >> n, n>0)
	{
		I = n;

		D = n - I;

		int cnt1 = 1;
		int cnt2 = 1;

		cnt1 = Ifunction(I,8);

		cnt2 = Dfunction(D);

		if (cnt1==0||cnt2==0)
		{
			cout << "NA" << endl;

			continue;
		}
		else
		{
			for (int i = 0; i < 8;i++)
			{
				cout << integer[i];
			}

			cout << ".";

			int flag = D*pow(2, cnt2);

			DIfunction(flag);

			for (int i = 0; i < 4; i++)
			{
				cout << decimal[i];
			}

			cout << endl;
		}

		
	}

	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <iomanip>
#include <string> 
#include <vector> 
using namespace std;
  
int main(){
    /*??£???????????????????????????
            int a[2];
            cin >> a[1] >> a[2];
            cout << "[+] " << a[1] + a[2] << endl;
            cout << "[-] " << a[1] - a[2] << endl;
            cout << "[*] " << a[1] * a[2] << endl;
            cout << "[/] " << a[1] / a[2] << endl;
    */

    double a,c,i;
    int b,e;
    while(cin >> a){
        string ans[2] = {"",""},aa;
        b = a;
        c  = a - b;
        int co[2] = {0,0},check = 0;
        while(b > 0){
            if(b % 2 == 1){
                ans[0] = "1" + ans[0];
            }else{
                ans[0] = "0" + ans[0];
            }
            b = b / 2;
            co[0]++;
            if(co[0] >= 8){check = 1;break;}
        }
        //cout << co[0] << endl;
        for(int i = co[0];7 >= i;i++){
            ans[0] = "0" + ans[0];
        }
        while(c != 0){
            c = c * 2;
            
            if(c >= 1){
                ans[1] = "1" + ans[1];
                co[1]++;
                if(co[1] >= 4){check = 1;break;}
                if(c == 1){break;}
            }else{
                ans[1] = "0" + ans[1];
                co[1]++;
                if(co[1] >= 4){check = 1;break;}
            }
            
        }
        //cout << co[1] << endl;
        for(int i = co[1];3 >= i;i++){
            ans[1] = ans[1] + "0";
        }        
        if(check == 1){
            cout << "NA" << endl;
        }else{
        cout << ans[0] << "." << ans[1] << endl;
    }
    }
}

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

int main(){
	double n;
	double b[12] = {128,64,32,16,8,4,2,1,0.5,0.25, 0.125,0.0625};
	while( cin >> n , n != -1.0 ){
		string s;
		for(int i=0 ; i < 12 ; i++ ){
			if( n >= b[i] ){
				n -= b[i];
				s += "1";
			}else{
				s += "0";
			}
			if( i == 7 )
				s += ".";
		}
		if( n > 0 )
			cout << "NA" << endl;
		else
			cout << s << endl;
	}
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main() {
	double d;
	while (cin >> d, d >= 0.) {
		if (d >= (double)(1 << 8)) {
			puts("NA");
			continue;
		}
		bitset<8>bit((int)d / 1);
		d -= (double)((int)d / 1);
		string s;
		rep(i, 4) {
			d *= 2.;
			s += to_string((int)(d / 1.));
			d -= (double)((int)(d / 1));
		}
		if (d) {
			puts("NA");
			continue;
		}
		cout << bit << '.' << s << endl;
	}
}