I’m trying to copy the rand() function from msvc in windows as I need to be able to use it for some code on Linux and would like to write the code in go. I found this stackoverflow question with the code and tried to mimic it below.
The issue is if I use the same seed of 36178 on windows I get these sequence of pseudo random numbers.
36178
19876
5709
27969
with the go code I only get the first random number the same and then they diverge and for the life of me I cant work out why. Assuming it’s something to do with the & 0x7fff bit in c really being undefined behaviour and go is doing something different.
36178
19876
32177
6811
Can anyone point me at what im doing wrong.