int RandomSource_next(int bits, double* seed) {
*seed = (((long long) *seed * 0x5DEECE66DLL) + 0xBLL) & ((1LL << 48) - 1);
return (int)((signed long long) *seed >> (48 - bits));
}
我认为这与地址有关。
最佳答案
很可能您将错误的地址作为种子
传递。也许您传递的不是地址而是值?
以下应该有效
double seed = 0;
RandomSource_next(48, &seed);
以下内容应该崩溃
RandomSource_next(48, 0);
关于objective-c - 为什么这段代码可以在 Objective-C 中运行?我的访问权限为 BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12032963/