Preferences

throwaway7767 parent
I looked at the RNG in TempleOS out of curiosity. I assumed he was mixing in some noise sources that could be explained as some kind of universal communication subchannel from god. Here's the relevant code (in HolyC of course):

  I32 RandI32()
  {//Random I32. Xor with TimsStamp.
    sys_rnd_seed.i32[0]=(1664525*sys_rnd_seed.i32[0]+1013904223)^GetTSC>>4;
    return sys_rnd_seed.i32[0];
  }
There are very similar RNG functions for signed and unsigned versions of 16, 32 and 64 bit ints. The GetTSC function just calls RDTSC, combines the two 32-bit halves in EAX and EDX and returns the recombined 64-bit TSC.

So the last returned value is used as part of the seed for the next one. The initial seed is set in kend.cpp:

  sys_rnd_seed  =93186752^GetTSC;
I have to admit, I was a bit disappointed that god would be quite so deterministic.

topkekz
he's now using Donald Knuth's LCG http://www.templeos.org/Wb/Kernel/KMathB.html
God does not throw dice. Apparently, he does use a linear congruential RNG.
pawadu
Now how does free will come into this?
Relevant xkcd: https://xkcd.com/221/
vuanotinf (dead)
dangsoocksdeek
No, not relevant. I wish someone would invent an ad blocker that instead blocked all gratuitous references to xkcd (i.e. all of them)

This item has no comments currently.