blob: e95ae274c0b6b32c49f67e27cc5da24e1b51098c [file] [log] [blame]
Geoff Lang49be2ad2014-02-28 13:05:51 -05001//
2// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7#include "random_utils.h"
8#include <time.h>
9#include <cstdlib>
10
11float RandomBetween(float min, float max)
12{
13 static bool randInitialized = false;
14 if (!randInitialized)
15 {
Minmin Gong3b26e232015-04-07 18:31:54 -070016 srand(static_cast<unsigned int>(time(NULL)));
Geoff Lang49be2ad2014-02-28 13:05:51 -050017 randInitialized = true;
18 }
19
20 const size_t divisor = 10000;
21 return min + ((rand() % divisor) / static_cast<float>(divisor)) * (max - min);
22}