projects
/
fio.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a77d139
)
make sure __rand_0_1 does not return 0.0
author
Song Liu
<songliubraving@fb.com>
Mon, 9 Nov 2015 22:32:12 +0000
(14:32 -0800)
committer
Jens Axboe
<axboe@fb.com>
Mon, 9 Nov 2015 22:54:39 +0000
(15:54 -0700)
Signed-off-by: Jens Axboe <axboe@fb.com>
lib/rand.h
patch
|
blob
|
blame
|
history
diff --git
a/lib/rand.h
b/lib/rand.h
index 3d78115d48580f3ea5a0afc3e6e4cbcd7206e83a..a95bd28b49041991abb8a1713ad80c9ef086742a 100644
(file)
--- a/
lib/rand.h
+++ b/
lib/rand.h
@@
-109,11
+109,11
@@
static inline double __rand_0_1(struct frand_state *state)
if (state->use64) {
uint64_t val = __rand64(&state->state64);
- return (
double) val
/ (FRAND64_MAX + 1.0);
+ return (
val + 1.0)
/ (FRAND64_MAX + 1.0);
} else {
uint32_t val = __rand32(&state->state32);
- return (
double) val
/ (FRAND32_MAX + 1.0);
+ return (
val + 1.0)
/ (FRAND32_MAX + 1.0);
}
}