Friday, September 15, 2023
HomeGolangReplicate c's rand() feature - Area

Replicate c’s rand() feature – Area


I’m attempting to duplicate the rand() feature from msvc in home windows as I require to be able to utilize it for some code on Linux as well as want to compose the code in go. I discovered this stackoverflow inquiry with the code as well as attempted to resemble it listed below.

The concern is if I make use of the exact same seed of 36178 on home windows I obtain these series of pseudo arbitrary numbers.

36178
19876
5709
27969

with the go code I just obtain the very first arbitrary number the exact same and after that they deviate as well as for the life of me I angle exercise why. Thinking it’s something to do with the & & 0x7fff little bit in c actually being undefined practices as well as go is doing something various.

36178
19876
32177
6811

Can any person direct me at what im doing incorrect.

RELATED ARTICLES

Most Popular

Recent Comments