File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,11 @@ PHP_METHOD(Random_Randomizer, nextFloat)
118
118
119
119
ZEND_PARSE_PARAMETERS_NONE ();
120
120
121
+ #ifndef __STDC_IEC_559__
122
+ zend_throw_exception (random_ce_Random_RandomException , "The nextFloat() method requires the underlying 'double' representation to be IEEE-754." , 0 );
123
+ RETURN_THROWS ();
124
+ #endif
125
+
121
126
result = 0 ;
122
127
total_size = 0 ;
123
128
do {
@@ -133,6 +138,7 @@ PHP_METHOD(Random_Randomizer, nextFloat)
133
138
* use the full 64 bits of the uint64_t, because we would
134
139
* introduce a bias / rounding error.
135
140
*/
141
+ ZEND_ASSERT (DBL_MANT_DIG == 53 );
136
142
const double step_size = 1.0 / (1ULL << 53 );
137
143
138
144
/* Use the upper 53 bits, because some engine's lower bits
You can’t perform that action at this time.
0 commit comments