我如何才能找到两人的最大功率小于数字,没有循环? [英] How i can find the the largest power of two less than a number without loop?

查看:98
本文介绍了我如何才能找到两人的最大功率小于数字,没有循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能找到的两家最大功率小于数字,没有循环? 例如:

  5输出= 4。
11输出= 8。
100输出= 64。
 

解决方案

假设你想两个小于X的最大功率,从

得到这个

 答= POW(2楼(LOG(X)/日志(2));
 

How i can find the largest power of two less than a number without loop ? Examples:

5 output = 4.
11 output = 8.
100 output = 64.

解决方案

Assuming you want the largest power of two less than x, you get this from

Ans=pow(2,floor(log(x)/log(2));

这篇关于我如何才能找到两人的最大功率小于数字,没有循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆