当前位置:网站首页>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
边栏推荐
- How do the top ten securities firms open accounts? In addition, is it safe to open a mobile account?
- 软件测试方法和技术 - 基础知识概括
- MATLAB之基础知识
- [MySQL learning notes 28] storage function
- matlab保存DB4i深度相机图片
- 漏刻有时API接口实战开发系列(14):身份证实名鉴权验证
- 关系数据库如何工作
- Office365 - how to use stream app to watch offline files at any time
- 她就是那个「别人家的HR」|ONES 人物
- Deep learning systematic learning
猜你喜欢

Instead of houses, another kind of capital in China is rising

Five combination boxing, solving six difficult problems on campus and escorting the construction of educational informatization

Introduction to kubernetes resource objects and common commands (II)

H5 页面设置了字体的粗细样式,但是在华为手机里微信打开访问样式不生效?

如何使用layui将数据库中的数据以表格的形式展现出来

PWN attack and defense world int_ overflow

【无标题】

Soft keyboard height error
![[introduction] approximate value](/img/6b/597178d848dd21110f36601fc31092.png)
[introduction] approximate value

【入门】输入整型数组和排序标识,对其元素按照升序或降序进行排序
随机推荐
力扣每日一题-第31天-202.快乐数
Oracle创建自增id
The triode is a great invention
长路漫漫、技术作伴
Android screen adaptation (using constraintlayout), kotlin array sorting
【入门】截取字符串
uni 热更新
Scala语言学习-07-构造器
力扣——求一组字符中的第一个回文字符
PWN attack and defense world int_ overflow
Caesar
EDA open source simulation tool verilator beginner 6: debugging examples
关系数据库如何工作
[MySQL learning notes 26] view
base64
Minecraft 1.16.5 module development (51) tile entity
Sorting out tcp/udp communication problems
她就是那个「别人家的HR」|ONES 人物
getInputStream() has already been called for this request
图扑软件通过 CMMI5 级认证!| 国际软件领域高权威高等级认证