数据类型 long - high 和 low 是什么意思?
Datatype long - what does high and low mean?
我正在使用 API,有时我会得到一个 JSON
,其中包含如下条目:
cooldown_complete_timestamp_ms: Long { low: 600206158, high: 342, unsigned: false}
我不知道如何处理这些数据 - 这是什么意思?
这不是常规的 JSON,其中 object
的值只能是 string
、number
、object
、array
、true
、false
或 null
.参见 http://www.json.org/。
您正在使用的 API 必须使用派生自 JSON 的内容进行回复。
您要针对哪个 API 编程?
我猜测 API 正在尝试 emulate/forcing 一个 64 位整数,类似于 LARGE_INTEGER
,一个 Win32 结构。
您正在查看的值可能是 342 * 2^32 + 600206158
,换句话说 1469479021390
。
high
和low
在这种情况下指定长数的高位和低位。
关于高位和低位有一个有趣的解释here:
Now, high/low order refers to the place value of the bits or words. For instance, in base 10, if we have four digits ABCD, the A digit has a place value of thousands, B hundreds, C tens, and D ones. In binary this is similar, except place values grow by powers of 2 - you'd have A eights, B fours, C twos, and D ones.
The high-order bit is the bit with the highest place value in a given block of bits. This may be a byte, word, dword, or whatever. The high-order word is the word containing the high-order bit; at least two words are required for this to make sense. Low order is similar, but using the least-significant place value instead.
假设我们的 Long 有 64 位。 low
将是 32 位低位(通常在右侧)的基数 10 表示,而 high
将是 32 位高位(通常在左侧)的基数 10 表示。
那个特定的 Long 表示法似乎源自 Long 库,一个帮助 tp 在 javascript 中表示长数的工具。
阅读 GitHub 上的源代码可以深入了解为什么选择这种表示形式,但最重要的是:
// The internal representation of a long is the two given signed, 32-bit values.
// We use 32-bit pieces because these are the size of integers on which
// Javascript performs bit-operations. For operations like addition and
// multiplication, we split each number into 16 bit pieces, which can easily be
// multiplied within Javascript's floating-point representation without overflow
// or change in sign.
您能够与 toNumber
的值进行交互,因为它们 implemented it 在库中。
我正在使用 API,有时我会得到一个 JSON
,其中包含如下条目:
cooldown_complete_timestamp_ms: Long { low: 600206158, high: 342, unsigned: false}
我不知道如何处理这些数据 - 这是什么意思?
这不是常规的 JSON,其中 object
的值只能是 string
、number
、object
、array
、true
、false
或 null
.参见 http://www.json.org/。
您正在使用的 API 必须使用派生自 JSON 的内容进行回复。
您要针对哪个 API 编程?
我猜测 API 正在尝试 emulate/forcing 一个 64 位整数,类似于 LARGE_INTEGER
,一个 Win32 结构。
您正在查看的值可能是 342 * 2^32 + 600206158
,换句话说 1469479021390
。
high
和low
在这种情况下指定长数的高位和低位。
关于高位和低位有一个有趣的解释here:
Now, high/low order refers to the place value of the bits or words. For instance, in base 10, if we have four digits ABCD, the A digit has a place value of thousands, B hundreds, C tens, and D ones. In binary this is similar, except place values grow by powers of 2 - you'd have A eights, B fours, C twos, and D ones.
The high-order bit is the bit with the highest place value in a given block of bits. This may be a byte, word, dword, or whatever. The high-order word is the word containing the high-order bit; at least two words are required for this to make sense. Low order is similar, but using the least-significant place value instead.
假设我们的 Long 有 64 位。 low
将是 32 位低位(通常在右侧)的基数 10 表示,而 high
将是 32 位高位(通常在左侧)的基数 10 表示。
那个特定的 Long 表示法似乎源自 Long 库,一个帮助 tp 在 javascript 中表示长数的工具。
阅读 GitHub 上的源代码可以深入了解为什么选择这种表示形式,但最重要的是:
// The internal representation of a long is the two given signed, 32-bit values.
// We use 32-bit pieces because these are the size of integers on which
// Javascript performs bit-operations. For operations like addition and
// multiplication, we split each number into 16 bit pieces, which can easily be
// multiplied within Javascript's floating-point representation without overflow
// or change in sign.
您能够与 toNumber
的值进行交互,因为它们 implemented it 在库中。