aboutsummaryrefslogtreecommitdiffstats
path: root/slobrok/src/vespa/slobrok/server/random.h
blob: dd7948fdec7c4bc9ca56f3923eca4ddb1dfc5a60 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <cstdlib>

namespace {

const double randmax = RAND_MAX;

// standard uniform distribution
double uniformRandom() {
    return random() / randmax;
}

double randomIn(double min, double max) {
    return min + (uniformRandom() * (max - min));
}

} // namespace <unnamed>