Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6154467
FloatGenerator.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
FloatGenerator.php
View Options
<?php
namespace
Eris\Generator
;
use
Eris\Generator
;
use
Eris\Generators
;
use
Eris\Random\RandomRange
;
function
float
()
{
return
Generators
::
float
();
}
/**
* @template-implements Generator<float>
*/
class
FloatGenerator
implements
Generator
{
public
function
__construct
()
{
}
public
function
__invoke
(
$size
,
RandomRange
$rand
)
{
$denominator
=
$rand
->
rand
(
1
,
$size
)
?:
1
;
$value
=
(
float
)
$rand
->
rand
(
0
,
$size
)
/
(
float
)
$denominator
;
$signedValue
=
$rand
->
rand
(
0
,
1
)
===
0
?
$value
:
$value
*
(-
1
);
return
GeneratedValueSingle
::
fromJustValue
(
$signedValue
,
'float'
);
}
public
function
shrink
(
GeneratedValue
$element
)
{
$value
=
$element
->
unbox
();
if
(
$value
<
0.0
)
{
return
GeneratedValueSingle
::
fromJustValue
(
min
(
$value
+
1.0
,
0.0
),
'float'
);
}
if
(
$value
>
0.0
)
{
return
GeneratedValueSingle
::
fromJustValue
(
max
(
$value
-
1.0
,
0.0
),
'float'
);
}
return
GeneratedValueSingle
::
fromJustValue
(
0.0
,
'float'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 8 2026, 05:15 (8 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f4/43/fb5fbdc1818f2bb7010cd2f05d87
Default Alt Text
FloatGenerator.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment