进制转换
package ch2; import java.util.Scanner; public class CG0311_2 { public static void main(String [] args) { Scanner sc = new Scanner(System.in); long res=0 ,base = 1; String str; str = sc.next(); int len = str.length(); for(int i = len-1;i>=0;i--) { if( str.charAt(i)==‘1‘ ) { res += base; } base*=2; } System.out.println(res); sc.close(); } }
double
package ch2; import java.util.Scanner; public class CG031101 { public static void main( String [] args ) { Scanner in = new Scanner(System.in); long a,b; a = in.nextInt(); b = in.nextInt(); System.out.printf("128-bit hexadecimal number:\n%016x%016x\n",a,b); a = a<<1; if( b<=-1 ) a=a+1; b=b<<1; System.out.printf("After doubling:\n%016x%016x\n",a,b); } }
原文:https://www.cnblogs.com/SunChuangYu/p/12462160.html