Geoff Lang | 49be2ad | 2014-02-28 13:05:51 -0500 | [diff] [blame] | 1 | // |
| 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 | |
| 11 | float RandomBetween(float min, float max) |
| 12 | { |
| 13 | static bool randInitialized = false; |
| 14 | if (!randInitialized) |
| 15 | { |
Jamie Madill | b3584fb | 2015-04-09 17:34:21 +0000 | [diff] [blame^] | 16 | srand(time(NULL)); |
Geoff Lang | 49be2ad | 2014-02-28 13:05:51 -0500 | [diff] [blame] | 17 | randInitialized = true; |
| 18 | } |
| 19 | |
| 20 | const size_t divisor = 10000; |
| 21 | return min + ((rand() % divisor) / static_cast<float>(divisor)) * (max - min); |
| 22 | } |