Idea: I didn't want to talk about it. I wanted to write it in java. I didn't find the corresponding function for double conversion .. C ++ should be used. I wanted to be lazy and use string directly, and then find a function that converts string to double. In the end, I still failed to use sstream, and the format would change .. In fact, the simplest method is to directly simulate it using arrays .. I always wanted to be lazy, and the result was circled... First, a double-Type Binary template is provided. The format is not considered here .. [Cpp] # include <sstream> # include <stdlib. h >#include <algorithm> # include <iostream> using namespace std; string: iterator it; string Trans (long Integer) {if (Integer = 0) return "0"; string temp = ""; while (Integer) {temp = char (Integer % 2 + 48) + temp; Integer/= 2;} return temp ;} string Trans (double Decimal) {string temp = ". "; int n = 20; while (Decimal & n) {Decimal * = 2; temp = temp + char (int (Decimal) + 48 ); decimal = Decimal-int (Decimal); n --;} return temp;} int main () {int I, j; double x; while (cin> x) {long Integer = long (x); double Decimal = x-Integer; double ans; string Ans = Trans (Integer) + Trans (Decimal ); cout <Ans <endl ;}} AC code: [cpp] # include <sstream> # include <stdlib. h >#include <algorithm> # include <iostream> using namespace std; string: iterator it; string Trans (long Integer) {if (Integer = 0) return "0"; string temp = ""; while (Integer) {temp = char (Integer % 2 + 48) + temp; Integer/= 2;} return temp ;} string Trans (double Decimal) {string temp = ". "; int n = 20; while (Decimal & n) {Decimal * = 2; temp = temp + char (int (Decimal) + 48 ); decimal = Decimal-int (Decimal); n --;} return temp;} int main () {int I, j; double x; while (cin> x) {long Integer = long (x); double Decimal = x-Integer; double ans; string Ans = Trans (Integer) + Trans (Decimal ); // cout <Ans <endl;/* Format Control Based on the question, and */int n = Ans. length (); while (-- n) {it = Ans. end ()-1; if (Ans [n] = '0') Ans. erase (it); else if (Ans [n] = '. ') {Ans. erase (it); break;} else break;} cout <Ans <endl;/* stringstream ss; ss <Ans; ss> ans; ss. clear (); cout <ans <endl ;*/}}