该数字32767的含义是什么? [英] What is the significance of the number, 32767?
问题描述
我意识到在某些编程语言中,随机数生成器生成的默认值为0到32767(例如,在php中,rand();将返回介于0和32767之间的浮点数).这样一个随机数的意义是什么? (因为它不是2的幂或类似的奇数.)
I realize in some programming languages, random number generators generate a default value of 0 to 32767 (for example, in php, rand(); will return a float between 0 and 32767). What is the significance of such a random number? (As it is not a power of two or anything special like that.)
推荐答案
32767 +1是2的幂
数字的二进制表示使用2的幂.因此,在4位结构中,0101
是2 ^ 0 x 1、2 ^ 1 x 0、2 ^ 2 x 1和2 ^ 3 x 0,即5.
32767 + 1 is a power of 2
Binary representation of numbers uses powers of 2. So, in an 4-bit structure, 0101
is 2^0 x 1, 2^1 x 0, 2^2 x 1, and 2^3 x 0 which is 5.
MSB用于有符号和无符号整数.
The MSB is used for sign and unsigned integers.
这篇关于该数字32767的含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!