50g: an interesting RAND anomaly
|
03-20-2018, 06:03 AM
Post: #20
|
|||
|
|||
RE: 50g: an interesting RAND anomaly
Hello,
Here is the random generator source code. This should give you ALL the info you may want (including the reason why you see what you are seeing). HP_Real fRand(uint64_t *Seed) { if (*Seed==0LL) *Seed= BaseSeed; HP_Real r; r.M= 0LL; uint64_t c= 0x2851130928467LL; for (int i= 13; --i>=0; i--) { r.M= dcb_muladd(r.M, *Seed, ((uint32_t)c)&15); // r.M= r.M+seed*low nibble of c *Seed<<= 4; c>>= 4; } *Seed= r.M&0x0fffffffffffffffLL; // update seed for next time r.e= -1; r.s= SignPos; // result's exponent is -1 and sign is pos while((r.M&0xf00000000000000LL)==0) { r.M <<= 4; r.e--; } // Normalize real r.M &= 0x0ffffffffffff000LL; // round to 12 significant digits return r; } Cheers, Cyrille Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)