Language: C++

import java.util.*;

class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    
    while (true) {
      double n = sc.nextDouble();
      if (n == -1) break;
      
      int left = (int)n;
      String lhs = Integer.toString(left, 2);
      
      if (lhs.length() > 8) {
        System.out.println("NA");
        continue;
      }
      
      double right = n % 1;
      String rhs = "";
      //int rem = 4;
      
      HashSet<Double> hs = new HashSet<Double>();
      hs.add(right);
      while (true) {
        right *= 2;
        if (hs.contains(right)) break;
        hs.add(right);
        
        rhs += (int)right;
        right %= 1;
      }
      if (rhs.length() > 4) {
        System.out.println("NA");
        continue;
      }
      /*
      while (rem-- > 0 && right != 0) {
         right *= 2;
         rhs += (int)right;
         right %= 1;
      }
      
      if (right != 0) {
        System.out.println("NA");
        continue;
      }*/
      
      while (lhs.length() != 8) lhs = "0" + lhs;
      while (rhs.length() != 4) rhs += "0";
      
      System.out.println(lhs + "." + rhs);
    }
  }
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:9: error: expected ':' before 'static'
    4 |   public static void main(String args[]) {
      |         ^~~~~~~
      |         :
a.cc:4:27: error: 'String' has not been declared
    4 |   public static void main(String args[]) {
      |                           ^~~~~~
a.cc:55:2: error: expected ';' after class definition
   55 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:5:5: error: 'Scanner' was not declared in this scope
    5 |     Scanner sc = new Scanner(System.in);
      |     ^~~~~~~
a.cc:8:18: error: 'sc' was not declared in this scope
    8 |       double n = sc.nextDouble();
      |                  ^~
a.cc:12:7: error: 'String' was not declared in this scope
   12 |       String lhs = Integer.toString(left, 2);
      |       ^~~~~~
a.cc:14:11: error: 'lhs' was not declared in this scope
   14 |       if (lhs.length() > 8) {
      |           ^~~
a.cc:15:9: error: 'System' was not declared in this scope
   15 |         System.out.println("NA");
      |         ^~~~~~
a.cc:19:24: error: invalid operands of types 'double' and 'int' to binary 'operator%'
   19 |       double right = n % 1;
      |                      ~ ^ ~
      |                      |   |
      |                      |   int
      |                      double
a.cc:20:14: error: expected ';' before 'rhs'
   20 |       String rhs = "";
      |              ^~~
a.cc:23:7: error: 'HashSet' was not declared in this scope
   23 |       HashSet<Double> hs = new HashSet<Double>();
      |       ^~~~~~~
a.cc:23:15: error: 'Double' was not declared in this scope; did you mean 'double'?
   23 |       HashSet<Double> hs = new HashSet<Double>();
      |               ^~~~~~
      |               double
a.cc:23:23: error: 'hs' was not declared in this scope
   23 |       HashSet<Double> hs = new HashSet<Double>();
      |                       ^~
a.cc:23:32: error: 'HashSet' does not name a type
   23 |       HashSet<Double> hs = new HashSet<Double>();
      |                                ^~~~~~~
a.cc:23:48: error: expected primary-expression before ')' token
   23 |       HashSet<Double> hs = new HashSet<Double>();
      |                                                ^
a.cc:30:9: error: 'rhs' was not declared in this scope
   30 |         rhs += (int)right;
      |         ^~~
a.cc:31:15: error: invalid operands of types 'double' and 'int' to binary 'operator%'
   31 |         right %= 1;
      |         ~~~~~~^~~~
a.cc:31:15: note:   in evaluation of 'operator%=(double, int)'
a.cc:33:11: error: 'rhs' was not declared in this scope
   33 |       if (rhs.length() > 4) {
      |           ^~~
a.cc:34:9: error: 'System' was not declared in this scope
   34 |         System.out.println("NA");
      |         ^~~~~~
a.cc:49:14: error: 'lhs' was not declared in this scope
   49 |       while (lhs.length() != 8) lhs = "0" + lhs;
      |              ^~~
a.cc:50:14: error: 'rhs' was not declared in this scope
   50 |       while (rhs.length() != 4) rhs += "0";
      |              ^~~
a.cc:52:7: error: 'System' was not declared in this scope
   52 |       System.out.println(lhs + "." + rhs);
      |       ^~~~~~
a.cc:52:26: error: 'lhs' was not declared in this scope
   52 |       System.out.println(lhs + "." + rhs);
      |                          ^~~
a.cc:52:38: error: 'rhs' was not declared in this scope
   52 |       System.out.println(lhs + "." + rhs);
      |                                      ^~~