mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
remove unnecessary casts everywhere
This commit is contained in:
@ -8,7 +8,7 @@ mut:
|
||||
}
|
||||
/**
|
||||
* new_splitmix64 - a Splitmix64 PRNG generator
|
||||
* @param seed the initial seed of the PRNG.
|
||||
* @param seed the initial seed of the PRNG.
|
||||
* @return a new Splitmix64 PRNG instance
|
||||
*/
|
||||
pub fn new_splitmix64(seed u64) Splitmix64 {
|
||||
@ -19,11 +19,11 @@ pub fn new_splitmix64(seed u64) Splitmix64 {
|
||||
* @return the generated pseudo random number
|
||||
*/
|
||||
[inline] pub fn (rng mut Splitmix64) next() u64 {
|
||||
rng.state += u64(0x9e3779b97f4a7c15)
|
||||
rng.state += (0x9e3779b97f4a7c15)
|
||||
mut z := rng.state
|
||||
z = (z ^ u64((z >> u64(30)))) * u64(0xbf58476d1ce4e5b9)
|
||||
z = (z ^ u64((z >> u64(27)))) * u64(0x94d049bb133111eb)
|
||||
return z ^ u64(z >> u64(31))
|
||||
z = (z ^ ((z >> u64(30)))) * (0xbf58476d1ce4e5b9)
|
||||
z = (z ^ ((z >> u64(27)))) * (0x94d049bb133111eb)
|
||||
return z ^ (z >> (31))
|
||||
}
|
||||
/**
|
||||
* Splitmix64.bounded_next - Get the next random number < bound
|
||||
@ -31,12 +31,12 @@ pub fn new_splitmix64(seed u64) Splitmix64 {
|
||||
* @return the generated pseudo random number
|
||||
*/
|
||||
[inline] pub fn (rng mut Splitmix64) bounded_next(bound u64) u64 {
|
||||
threshold := u64( -bound % bound )
|
||||
threshold := -bound % bound
|
||||
for {
|
||||
r := rng.next()
|
||||
if r >= threshold {
|
||||
return u64( r % bound )
|
||||
}
|
||||
return r % bound
|
||||
}
|
||||
}
|
||||
return u64(0)
|
||||
}
|
||||
|
Reference in New Issue
Block a user