当前位置:网站首页>Find the nearest n-th power of 2
Find the nearest n-th power of 2
2022-07-01 08:00:00 【Brother Hu learns programming with you】
public class Test {
public static void main(String[] args) {
System.out.println(ceilingPowerOfTwo(1));
System.out.println(ceilingPowerOfTwo(3));
System.out.println(ceilingPowerOfTwo(5));
System.out.println(ceilingPowerOfTwo(7));
System.out.println(ceilingPowerOfTwo(13));
System.out.println(ceilingPowerOfTwo(19));
System.out.println(ceilingPowerOfTwo(27));
}
public static int ceilingPowerOfTwo(int x){
return 1 << 32 - Integer.numberOfLeadingZeros(x - 1);
}
}
among Integer.numberOfLeadingZeros Find a number with a continuous number on the left 0 The number of
边栏推荐
- 奥迪AUDI EDI 项目中供应商需要了解哪些信息?
- Kickback -- find the first palindrome character in a group of characters
- Thesis learning -- Analysis and Research on similarity query of hydrological time series
- What information does the supplier need to know about Audi EDI project?
- Five combination boxing, solving six difficult problems on campus and escorting the construction of educational informatization
- 力扣——求一组字符中的第一个回文字符
- web254
- Sqlalchemy creating MySQL_ Table
- 【网站架构】一招搞定90%的分布式事务,实打实介绍数据库事务、分布式事务的工作原理应用场景
- 【入门】截取字符串
猜你喜欢
随机推荐
Gui Gui programming (XV) - use scale to control font size changes
关系数据库如何工作
【入门】输入整型数组和排序标识,对其元素按照升序或降序进行排序
Contenttype comparison of all types
Gru of RNN
长路漫漫、技术作伴
How to make the two financial transactions faster
Office365 - how to use stream app to watch offline files at any time
Scala语言学习-07-构造器
Oracle创建自增id
php laravel微信支付
base64
Lm08 mesh series mesh inversion (fine)
How do the top ten securities firms open accounts? In addition, is it safe to open a mobile account?
【mysql学习笔记25】sql语句优化
Uni hot update
The Windows C disk is full
SQL number injection and character injection
Gdip - hatchbrush pattern table
H5 页面设置了字体的粗细样式,但是在华为手机里微信打开访问样式不生效?