@@ -155,26 +155,25 @@ macro_rules! arbitrary_float {
155
155
where G : Gen
156
156
{
157
157
let special = [
158
- -0.0 , 0.0 , 1.0 , $ty:: NAN , $ty:: INFINITY , -$ty:: INFINITY
158
+ -0.0 , 0.0 , $ty:: NAN , $ty:: INFINITY , -$ty:: INFINITY
159
159
] ;
160
160
161
- if g. gen ( ) { // Random special case
162
- let index: usize = g. gen ( ) ;
163
- $TY( special[ index % special. len( ) ] )
164
- } else if g. gen ( ) { // Random anything
161
+ if g. gen_weighted_bool( 10 ) { // Random special case
162
+ $TY( * g. choose( & special) . unwrap( ) )
163
+ } else if g. gen_weighted_bool( 10 ) { // NaN variants
165
164
let sign: bool = g. gen ( ) ;
166
165
let exponent: <$ty as Float >:: Int = g. gen ( ) ;
167
- let significand: <$ty as Float >:: Int = g . gen ( ) ;
166
+ let significand: <$ty as Float >:: Int = 0 ;
168
167
$TY( $ty:: from_parts( sign, exponent, significand) )
169
168
} else if g. gen ( ) { // Denormalized
170
169
let sign: bool = g. gen ( ) ;
171
170
let exponent: <$ty as Float >:: Int = 0 ;
172
171
let significand: <$ty as Float >:: Int = g. gen ( ) ;
173
172
$TY( $ty:: from_parts( sign, exponent, significand) )
174
- } else { // NaN variants
173
+ } else { // Random anything
175
174
let sign: bool = g. gen ( ) ;
176
175
let exponent: <$ty as Float >:: Int = g. gen ( ) ;
177
- let significand: <$ty as Float >:: Int = 0 ;
176
+ let significand: <$ty as Float >:: Int = g . gen ( ) ;
178
177
$TY( $ty:: from_parts( sign, exponent, significand) )
179
178
}
180
179
}
0 commit comments