MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / stochasticRound

Method stochasticRound

source/core/StarRandom.cpp:173–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173int64_t RandomSource::stochasticRound(double val) {
174 double fpart = val - floor(val);
175 if (randd() < fpart)
176 return ceil(val);
177 else
178 return floor(val);
179}
180
181uint32_t RandomSource::gen32() {
182 uint64_t a = 809430660;

Callers 2

stochasticRoundFunction · 0.80
TESTFunction · 0.80

Calls 1

randdFunction · 0.85

Tested by 1

TESTFunction · 0.64