当前位置:网站首页>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
边栏推荐
- [force deduction 10 days SQL introduction] Day9 control flow
- 2022 Guangdong Provincial Safety Officer a certificate third batch (main person in charge) special operation certificate examination question bank simulated examination platform operation
- 十大劵商如何开户?另外,手机开户安全么?
- How to check ad user information?
- 源代码加密的意义和措施
- Tupu software has passed CMMI5 certification| High authority and high-level certification in the international software field
- SQL number injection and character injection
- 如何使用layui将数据库中的数据以表格的形式展现出来
- Rk3399 platform development series explanation (network debugging) 7.30. What will affect the sending process of TCP packets?
- 奥迪AUDI EDI 项目中供应商需要了解哪些信息?
猜你喜欢

Caesar

How to troubleshoot SharePoint online map network drive failure?

【网站架构】一招搞定90%的分布式事务,实打实介绍数据库事务、分布式事务的工作原理应用场景

She is the "HR of others" | ones character

【入门】输入n个整数,输出其中最小的k个

Erreur de hauteur du clavier souple

凸印的印刷原理及工艺介绍

Download xshell and xftp

Lm08 mesh series mesh inversion (fine)

2022 test questions and mock examinations for main principals of hazardous chemicals business units
随机推荐
Lm08 mesh series mesh inversion (fine)
The Windows C disk is full
sqlalchemy创建MySQL_Table
[MySQL learning notes 25] SQL statement optimization
Gdip - hatchBrush图案表
Differential: definition of total differential, partial derivative, gradient
She is the "HR of others" | ones character
2022 tea master (intermediate) recurrent training question bank and answers
Set up file server Minio for quick use
Access report realizes subtotal function
Five combination boxing, solving six difficult problems on campus and escorting the construction of educational informatization
ONES 创始人王颖奇对话《财富》(中文版):中国有没有优秀的软件?
EDA开源仿真工具verilator入门6:调试实例
三极管是一项伟大的发明
如何使用layui将数据库中的数据以表格的形式展现出来
[getting started] enter the integer array and sorting ID, and sort its elements in ascending or descending order
Soft keyboard height error
Learn the knowledge you need to know about the communication protocol I2C bus
php laravel微信支付
Php laraver Wechat payment