我是否需要使用 long 类型将 2166136261 存储在 Java 中?
Do I need to use type long to store 2166136261 in Java?
我正在尝试实现一个简单的 FNV hash function in Java. The function requires the value 2166136261 as a function parameter. In one online source,该数字以十六进制分配如下:
private static final int FNV_32_INIT = 0x811C9DC5;
但我认为这是不正确的,因为 2166136261 大于 2147483647,后者是 int
可以容纳的最大值。
我是否正确地假设我至少需要一个 long
类型的变量来存储值,无论是十进制还是十六进制?
编辑:
此算法中用作偏移基础的值是任意的,因此 FNV_32_INIT = 2166136261 或其他值无关紧要:
Regarding the offset_basis value:
The switch from FNV-0 to FNV-1 was purely to change the offset_basis
to a non-zero value. The selection of that non-zero value is
arbitrary. The string: chongo /../\ was used
because the tester was looking at an EMail message from Landon in
Landon's standard EMail signature line. Actually the person who did
that did not see very well. Landon, today, uses ()'s instead of <>'s
and his ASCII bats use "oo" eyes instead of ".." as in: chongo (Landon
Curt Noll) /\oo/\ We didn't bother correcting her error because it
does not matter. In the general case, almost any offset_basis will
serve so long as it is non-zero.
是的,你是对的。
无论是十进制、十六进制、二进制、八进制、64 进制还是任何其他基数,这些表达式都表示相同的大小。
我正在尝试实现一个简单的 FNV hash function in Java. The function requires the value 2166136261 as a function parameter. In one online source,该数字以十六进制分配如下:
private static final int FNV_32_INIT = 0x811C9DC5;
但我认为这是不正确的,因为 2166136261 大于 2147483647,后者是 int
可以容纳的最大值。
我是否正确地假设我至少需要一个 long
类型的变量来存储值,无论是十进制还是十六进制?
编辑:
此算法中用作偏移基础的值是任意的,因此 FNV_32_INIT = 2166136261 或其他值无关紧要:
Regarding the offset_basis value:
The switch from FNV-0 to FNV-1 was purely to change the offset_basis to a non-zero value. The selection of that non-zero value is arbitrary. The string: chongo /../\ was used because the tester was looking at an EMail message from Landon in Landon's standard EMail signature line. Actually the person who did that did not see very well. Landon, today, uses ()'s instead of <>'s and his ASCII bats use "oo" eyes instead of ".." as in: chongo (Landon Curt Noll) /\oo/\ We didn't bother correcting her error because it does not matter. In the general case, almost any offset_basis will serve so long as it is non-zero.
是的,你是对的。
无论是十进制、十六进制、二进制、八进制、64 进制还是任何其他基数,这些表达式都表示相同的大小。