@@ -130,13 +130,9 @@ PHP_METHOD(Random_Randomizer, nextFloat)
130
130
}
131
131
/* }}} */
132
132
133
- /* {{{ Generates a random float within [min, max) .
133
+ /* {{{ Generates a random float within a configurable interval .
134
134
*
135
- * The algorithm used is the γ-section algorithm as published in:
136
- *
137
- * Drawing Random Floating-Point Numbers from an Interval. Frédéric
138
- * Goualard, ACM Trans. Model. Comput. Simul., 32:3, 2022.
139
- * https://doi.org/10.1145/3503512
135
+ * This method uses the γ-section algorithm by Frédéric Goualard.
140
136
*/
141
137
PHP_METHOD (Random_Randomizer , getFloat )
142
138
{
@@ -169,32 +165,30 @@ PHP_METHOD(Random_Randomizer, getFloat)
169
165
}
170
166
171
167
RETURN_DOUBLE (php_random_gammasection_closed_open (randomizer -> algo , randomizer -> status , min , max ));
172
- }
173
- if (zend_string_equals_literal (bounds_name , "ClosedClosed" )) {
168
+ } else if (zend_string_equals_literal (bounds_name , "ClosedClosed" )) {
174
169
if (UNEXPECTED (max < min )) {
175
170
zend_argument_value_error (2 , "must be greater than or equal to argument #1 ($min)" );
176
171
RETURN_THROWS ();
177
172
}
178
173
179
174
RETURN_DOUBLE (php_random_gammasection_closed_closed (randomizer -> algo , randomizer -> status , min , max ));
180
- }
181
- if (zend_string_equals_literal (bounds_name , "OpenClosed" )) {
175
+ } else if (zend_string_equals_literal (bounds_name , "OpenClosed" )) {
182
176
if (UNEXPECTED (max <= min )) {
183
177
zend_argument_value_error (2 , "must be greater than argument #1 ($min)" );
184
178
RETURN_THROWS ();
185
179
}
186
180
187
181
RETURN_DOUBLE (php_random_gammasection_open_closed (randomizer -> algo , randomizer -> status , min , max ));
188
- }
189
- if (zend_string_equals_literal (bounds_name , "OpenOpen" )) {
182
+ } else if (zend_string_equals_literal (bounds_name , "OpenOpen" )) {
190
183
if (UNEXPECTED (max <= min )) {
191
184
zend_argument_value_error (2 , "must be greater than argument #1 ($min)" );
192
185
RETURN_THROWS ();
193
186
}
194
187
195
188
RETURN_DOUBLE (php_random_gammasection_open_open (randomizer -> algo , randomizer -> status , min , max ));
189
+ } else {
190
+ ZEND_UNREACHABLE ();
196
191
}
197
- ZEND_UNREACHABLE ();
198
192
}
199
193
/* }}} */
200
194
0 commit comments