I want to convert binary to an integer, multiply it by 17, then convert it back to binary. This is my code:
Scanner scan = new Scanner(System.in);
String n = scan.nextLine();
long j = Long.parseLong(n, 2);
j = j * 17;
System.out.println(Long.toBinaryString(j));
I originally made j an int but changed it once I got a bigger test case:
10001111110001000101000001000100111100110101100011000011011001111000100110110000110101110101100001001100010111000101000100010010011000000010010
It had a NumberFormatException, which makes sense because longs can only store a limited amount of digits, so are there any datatypes for very long integers?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…