mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 08:39:53 +00:00
Random generator with signed int/float methods
This commit is contained in:
parent
3cbcb4871a
commit
26772082da
@ -47,10 +47,18 @@ class Random{
|
|||||||
return Utils::readInt($this->nextBytes(4)) & 0x7FFFFFFF;
|
return Utils::readInt($this->nextBytes(4)) & 0x7FFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function nextSignedInt(){
|
||||||
|
return Utils::readInt($this->nextBytes(4));
|
||||||
|
}
|
||||||
|
|
||||||
public function nextFloat(){
|
public function nextFloat(){
|
||||||
return $this->nextInt() / 0x7FFFFFFF;
|
return $this->nextInt() / 0x7FFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function nextSignedFloat(){
|
||||||
|
return $this->nextSignedInt() / 0x7FFFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
public function nextBytes($byteCount){
|
public function nextBytes($byteCount){
|
||||||
$bytes = "";
|
$bytes = "";
|
||||||
for($i = 0; $i < $byteCount; ++$i){
|
for($i = 0; $i < $byteCount; ++$i){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user