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 <stdio.h>
#include <math.h>
using namespace std;
int main()
{
    double n,m;
    int a = 0;
    int res = 0;
    int bai = 1;
    double ans = 0,ahokusa = 0;
    while(cin >> n)
    {
        if(n == -1.0)return 0;
        while(1)
        {
            a = n;
            m = n - a;
            if(a > 256 || m < 0.0625)
            {
                puts("NA");
            }
            else
            {
                while(a > 0)
                {
                    res += (a%2)*bai;
                    a /= 2;
                    bai *= 10;
                }
            }
            ans += res;
            for(int i = 2; i < 17; pow(2,i))
            {
                if(m == 1/i)ahokusa += 1/i;
                if(i == 16 && ahokusa == 0)
                {
                    puts("NA");
                    break;
                }
            }
            printf("%8.4f\n",ans);
            break;
        }
    }

    return 0;
}

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<bits/stdc++.h>
using namespace std;

int main(){
  double n;
  while(1){
    cin >> n;
    if(n < 0) break;
    int sei = (int)n;
    int st = sei;
    double syo = n - (double)sei;
    double d = 1;
    double temp = syo;
    for(int i=8;i>0;i--){
      int tmp = (int)pow(2.0,(double)i-1);
      if(st >= tmp){
	st -= tmp;
      }
    }
    for(int i=0;i<4;i++){
      d = d / 2.0;
      if(temp >= d){
	temp -= d;
      }
    }
    if(st != 0 || temp != 0){
      cout << "NA" << endl;
      continue;
    }
    for(int i=8;i>0;i--){
      int tmp = (int)pow(2.0,(double)i-1);
      if(sei >= tmp){
	cout << "1";
	sei -= tmp;
      }
      else cout << "0";
    }
    cout << ".";
    double tt=1;
    for(int i=0;i<4;i++){
      tt = tt / 2.0;
      if(syo >= tt){
	cout << "1";
	syo -= tt;
      }
      else cout << "0";
    }
    cout << endl;
  }
}

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

int main(){
	double n;
	while(1){
		cin>>n;
		if(n<0)break;
		string ans="";
		bool check=true;
		int size;
		for(int i=7;i>=-4;i--){
			if(n>=pow(2,i)){
				n-=pow(2,i);
				ans+='1';
			}else{
				ans+='0';
			}
			if(n<1e-6){
				check=false;
				break;
			}
			if(i==0)ans+='.';
		}
		size=ans.size();
		if(ans.size()<=8){
			rep(i,8-size)ans+='0';
			ans+=".0000";
		}else if(ans.size()<13)rep(i,13-size)ans+='0';
		if(!check)cout<<ans<<endl;
		else cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include<stdio.h>


#define limit 1 << 12



int main()
{
	double shousuu ;
	int seisuu ;


	int i ;
	while( 1 )
	{
		scanf( "%lf" ,&shousuu ) ;


		if( shousuu < 0 )
		{
			return 0 ;
		}


		shousuu *= 16 ;

		seisuu = ( int )shousuu ;


		if( shousuu >= limit || shousuu - seisuu != 0 )
		{
			puts( "NA" ) ;
		}


		else
		{
			i = 12 ;
			while( i-- )
			{
				if( i == 3 )
				{
					printf( "." ) ;
				}

				printf( "%d" ,( seisuu >> 11 ) & 1 ) ;


				seisuu <<= 1 ;
			}

			puts( "" ) ;
		}
	}
}

C++: #include <stdio.h>

int main()
{
    double x, xx;
    int    y, z;
    int i;

    scanf("%lf", &x);
    while (x >= 0) {

        xx = x * 16;
        y = (int)(xx);
        z = (int)x;
        if (z > 256 || xx - (double)y != 0) {
            printf("NA\n");
        } else {
            for (i = 0; i < 8; i++) {
                printf("%d", y >> 11);
                y = y << 1 & 0x00000fff;
            }
            putchar('.');
            for (i = 0; i < 4; i++) {
                printf("%d", y >> 11);
                y = y << 1 & 0x00000fff;
            }
            putchar('\n');

        }

        scanf("%lf", &x);
    }

    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <iomanip>
#include <string> 
#include <vector> 
using namespace std;
  
int main(){

    double a,c,i;
    int b,e;
    while(cin >> a){
        if(a < 0){break;}
        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;}
        }
        for(int i = co[0];7 >= i;i++){
            ans[0] = "0" + ans[0];
        }
        while(c != 0){
            c = c * 2;
            
            if(c >= 1){
                ans[1] = ans[1] + "1";
                co[1]++;
                if(co[1] > 4){check = 1;break;}
                if(c == 1){break;}
            }else{
                ans[1] = ans[1] + "0";
                co[1]++;
                if(co[1] > 4){check = 1;break;}
            }
            
        }
        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 <bits/stdc++.h>
using namespace std;

constexpr double EPS = 1e-8;

double b[12];

bool solve(){
    double x;
    cin >> x;
    if(x < 0) return false;
    string ans = "";
    for(int i=0;i<12;i++){
        if(x > b[i] - EPS){
            x -= b[i];
            ans += '1';
        }else{
            ans += '0';
        }
        if(i == 7) ans += '.';
    }
    if(x < EPS){
        cout << ans << endl;
    }else{
        cout << "NA" << endl;
    }
    return true;
}

int main(){
    b[0] = 1<<7;
    for(int i=0;i<11;i++){
        b[i+1] = b[i]/2;
    }
    while(solve());
    return 0;
}