slash
BAN USER//fraction part i have terminated to 10 digits
input=input.replaceAll("[^0-9.]+", "E");
if(input.contains("E")||input.indexOf('.')!=input.lastIndexOf('.'))
System.out.println("ERROR");
else{
int i = input.indexOf(".");
int n = Integer.parseInt(input.substring(0, i));
StringBuffer binary=new StringBuffer();
while(n>0){
int j = n%2;
binary.append(j);
n=n/2;
}
binary = binary.reverse();
binary.append(".");
double f = Double.parseDouble(input.substring(i));
int count =0;
while(f>0&&count<10){
f=f*2;
input=""+f;
int p = input.indexOf(".");
int a = Integer.parseInt(input.substring(0, i));
f = Double.parseDouble(input.substring(p));
binary.append(a);
count++;
}
System.out.println(binary.toString());
Repgoamgivheler, Accountant at Lava
I am working as a nurse in Bali Boer Cafarius. I enjoy relationships with patients and their families. It has ...
}
- slash June 20, 2012