Skip to content

motal/Java-Coding-Tip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Java Coding Tip

Bit shift

int a = 2_000_000_000;
int b = 1_000_000_000;
System.out.println((a + b) / 2);
System.out.println((a + b) >> 1);
System.out.println(a + (b - a) / 2);
System.out.println((a + b) >>> 1);
OUTPUT:
-647483648
-647483648
1500000000
1500000000

About

For better code of latest Java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages