MCPcopy Create free account
hub / github.com/SmingHub/Sming / getRandom

Function getRandom

Sming/Wiring/WMath.cpp:31–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31static int getRandom()
32{
33 auto next = seed;
34 next *= 1103515245;
35 next += 12345;
36 auto result = (unsigned int)(next / 65536) % 2048;
37
38 next *= 1103515245;
39 next += 12345;
40 result <<= 10;
41 result ^= (unsigned int)(next / 65536) % 1024;
42
43 next *= 1103515245;
44 next += 12345;
45 result <<= 10;
46 result ^= (unsigned int)(next / 65536) % 1024;
47
48 seed = next;
49
50 return int(result);
51}
52
53void randomSeed(uint16_t seed)
54{

Callers 1

randomFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected