Skip to content

Commit d2f7f26

Browse files
committed
COMMON: rand() replacment using PCG
1 parent 30c2b24 commit d2f7f26

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/common/random.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
// This file is part of SmallBASIC
22
//
3-
// lowlevel device (OS) I/O
3+
// random number generator, see:
4+
// https://en.wikipedia.org/wiki/Permuted_congruential_generator
5+
// https://www.pcg-random.org/download.html
46
//
57
// This program is distributed under the terms of the GPL v2.0 or later
68
// Download the GNU Public License (GPL) from www.gnu.org
79
//
8-
// Copyright(C) 2000 Nicholas Christopoulos
10+
// Copyright(C) 2021 Chris Warren-Smith
911

1012
#include "config.h"
1113

1214
#include "common/sys.h"
1315
#include <stdint.h>
1416
#include <limits.h>
1517

16-
// see:
17-
// https://en.wikipedia.org/wiki/Permuted_congruential_generator
18-
// https://www.pcg-random.org/download.html
19-
2018
static uint64_t state = 0x4d595df4d0f33173;
2119
static uint64_t multiplier = 6364136223846793005u;
2220
static uint64_t increment = 1442695040888963407u;

src/platform/android/jni/common/Android.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ LOCAL_SRC_FILES := \
3131
$(COMMON)/device.c \
3232
$(COMMON)/screen.c \
3333
$(COMMON)/system.c \
34+
$(COMMON)/random.c \
3435
$(COMMON)/eval.c \
3536
$(COMMON)/extlib.c \
3637
$(COMMON)/file.c \

0 commit comments

Comments
 (0)