From 5b9f35ec7509e169f58500b66712eafb075d0b36 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Sun, 11 Oct 2009 16:46:46 +0200 Subject: Added a simple random generator --- Source/Kernel/Library/Rand.ns.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Source/Kernel/Library/Rand.ns.cpp (limited to 'Source/Kernel/Library/Rand.ns.cpp') diff --git a/Source/Kernel/Library/Rand.ns.cpp b/Source/Kernel/Library/Rand.ns.cpp new file mode 100644 index 0000000..e568678 --- /dev/null +++ b/Source/Kernel/Library/Rand.ns.cpp @@ -0,0 +1,18 @@ +#include "Rand.ns.h" + +namespace Rand { + +u32int m = 2073741824, a = 50000, b = 1534; +u64int current = RANDOM_SEED; + +u64int rand() { + current = (u32int)(a*current + b); + while (current > m) current -= m; + return current; +} + +u64int max() { + return m; +} + +} -- cgit v1.2.3