我想实现快速随机生成的,我遇到了这个网站:https://en.wikipedia.org/wiki/Xorshift,其中提出了如下的代码C++ const使用。我可以删除它吗?
#include <stdint.h>
/* The state must be seeded so that it is not everywhere zero. */
uint64_t s[2];
uint64_t xorshift128plus(void) {
uint64_t x = s[0];
uint64_t const y = s[1];
s[0] = y;
x ^= x << 23; // a
s[1] = x^y^(x >> 17)^(y >> 26); // b, c
return s[1] + y;
}
我想知道如果常量在这里有什么用,我可以放心地将其删除?
这是C.不要相信短语“C/C++”。 – Ohashi
是的,你可以,为什么你认为你不能?你为什么要删除它? –