blob: b7b7ae3f7aa325944ba981f5389a3d8e77276f52 [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 {
Jamie Madillb3584fb2015-04-09 17:34:21 +000016 srand(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}