summaryrefslogtreecommitdiff
path: root/lib/std/rand.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-05-17 22:00:50 -0700
committerOri Bernstein <ori@eigenstate.org>2016-05-17 22:00:50 -0700
commit7aac15b2bfcc5eec279aa14f9f199685f9d7e0d9 (patch)
treec9434a55ea6850aee7103f608c6333cfe3148d60 /lib/std/rand.myr
parentc96238b89583ed91e92ad909c507797d00015e95 (diff)
downloadmc-7aac15b2bfcc5eec279aa14f9f199685f9d7e0d9.tar.gz
New syntax for casts.
Diffstat (limited to 'lib/std/rand.myr')
-rw-r--r--lib/std/rand.myr14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/std/rand.myr b/lib/std/rand.myr
index 011fec2..fce743c 100644
--- a/lib/std/rand.myr
+++ b/lib/std/rand.myr
@@ -71,7 +71,7 @@ type rng = struct
var _rng : rng#
const __init__ = {
- _rng = mksrng(now() castto(uint32))
+ _rng = mksrng((now() : uint32))
}
/* allocates and initializes a random number generator */
@@ -146,7 +146,7 @@ generic rngrandnum = {rng -> @a::(integral,numeric)
val = 0
for var i = 0; i < sizeof(@a)/4; i++
val <<= 8*sizeof(@a)
- val |= rand32(rng) castto(@a::(integral,numeric))
+ val |= (rand32(rng) : @a::(integral,numeric))
;;
-> val
}
@@ -176,14 +176,14 @@ const rngrandbytes = {rng, buf
n = 0
for var i = 0; i < buf.len/4; i++
r = rand32(rng)
- buf[n++] = (r >> 0 & 0xff) castto(byte)
- buf[n++] = (r >> 8 & 0xff) castto(byte)
- buf[n++] = (r >> 16 & 0xff) castto(byte)
- buf[n++] = (r >> 32 & 0xff) castto(byte)
+ buf[n++] = (r >> 0 & 0xff : byte)
+ buf[n++] = (r >> 8 & 0xff : byte)
+ buf[n++] = (r >> 16 & 0xff : byte)
+ buf[n++] = (r >> 32 & 0xff : byte)
;;
r = rand32(rng)
for ; n != buf.len; n++
- buf[n] = (r & 0xff) castto(byte)
+ buf[n] = (r & 0xff : byte)
r >>= 8
;;
-> n