Skip to content

Commit

Permalink
unsigned integers fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
selimanac committed Aug 22, 2019
1 parent f87465b commit 5076d20
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ You can use PCG Random in your own project by adding this project as a [Defold l

### rnd.number()

Returns a 32 bit integer
Returns a 32 bit unsigned integer.

### rnd.range(min, max)

Returns a 32 bit integer between min and max values.
Returns a 32 bit unsigned integer between min and max values. Only for positive numbers(unsigned integers).
Same as **math.random(3,20)**
**math.random(90)** => rnd.range(1, 90)
**math.random(90)** == rnd.range(1, 90)

### rnd.double()

Expand Down
6 changes: 3 additions & 3 deletions main/main.script
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function init(self)
print("Number")
for i = 1, 10 do
num = rnd.number()
print("32 bit integer: " .. num)
print("32 bit unsigned integer: " .. num)
end
print("--------------------")
print("TOSS A COIN")
Expand All @@ -26,7 +26,7 @@ function init(self)
print("Roll: " .. num)
end
print("--------------------")
print("DOUBLE 0<->1 ")
print("DOUBLE 0 -> 1 ")
for i = 1, 10 do
d = rnd.double()
print("Double: " .. d) -- range [0,1]
Expand All @@ -38,7 +38,7 @@ function init(self)
y = rnd.range(50, 70)
print("Range:", x, y)
num = rnd.range(x, y)
print("Result: " .. num)
print("Result (unsigned int): " .. num)
end
print("--------------------")
print("TEST")
Expand Down
6 changes: 3 additions & 3 deletions pcgrandom/ext.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name: "pcgrandom"
platforms:
x86_64-osx:
context:
flags: ["-std=c++11", "-stdlib=libc++"]
flags: ["-std=c++11"]
libs: ["z","c++"]

arm64-ios:
context:
flags: ["-std=c++11", "-stdlib=libc++"]
flags: ["-std=c++11"]
libs: ["z","c++"]

armv7-ios:
context:
flags: ["-std=c++11", "-stdlib=libc++"]
flags: ["-std=c++11"]
6 changes: 3 additions & 3 deletions pcgrandom/src/pcgrandom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
//#include <time.h> // You can use time instead of entropy

static pcg32_random_t rng;
static int32_t num;
static int32_t min;
static int32_t max;
static uint32_t num;
static uint32_t min;
static uint32_t max;
static double d;

static int double_num(lua_State *L)
Expand Down

0 comments on commit 5076d20

Please sign in to comment.