package rew;
import java.util.Scanner;
public class Example1 {
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
System.out.println("请输入一个整数");
long number=scan.nextLong();
System.out.println("您输入的数字是:"+number);
System.out.println("您输入的数字乘以2的运算结果是:"+(number<<1));
System.out.println("您输入的数字乘以16的运算结果是:"+(number<<4));
}
import java.util.Scanner;
public class Example1 {
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
System.out.println("请输入一个整数");
long number=scan.nextLong();
System.out.println("您输入的数字是:"+number);
System.out.println("您输入的数字乘以2的运算结果是:"+(number<<1));
System.out.println("您输入的数字乘以16的运算结果是:"+(number<<4));
}
}
结果:
结果说明:
相当于输入的数乘以2的n次方
位移运算:
移位运