多少位,你需要存储多少? [英] How many bits do you need to store a number?

查看:116
本文介绍了多少位,你需要存储多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您将有多少位需要存储一些例如在数十亿美元。你必须使用LOG2 N至发现这一点?

How many bits would you need to store a number for example in the billions. Would you have to use the log2 N to find this out?

推荐答案

因为我已经看到了答案报道不正确,因此很多时候,我以为我会张贴了正确的答案。

Since I've seen the answer reported incorrectly so many times, I thought I would post the correct answer.

重新present的正整数n是需要的比特数目

The number of bits needed to represent the positive integer n is

bits = floor( log2(n) + 1 )

在这里LOG2意味着日志基地2。

where log2 means log base 2.

这篇关于多少位,你需要存储多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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