@@ -249,98 +249,98 @@ fn test_classify() {
249
249
#[ cfg( not( miri) ) ]
250
250
#[ cfg( target_has_reliable_f128_math) ]
251
251
fn test_floor ( ) {
252
- assert_approx_eq ! ( 1.0f128 . floor( ) , 1.0f128 , TOL_PRECISE ) ;
253
- assert_approx_eq ! ( 1.3f128 . floor( ) , 1.0f128 , TOL_PRECISE ) ;
254
- assert_approx_eq ! ( 1.5f128 . floor( ) , 1.0f128 , TOL_PRECISE ) ;
255
- assert_approx_eq ! ( 1.7f128 . floor( ) , 1.0f128 , TOL_PRECISE ) ;
256
- assert_approx_eq ! ( 0.0f128 . floor( ) , 0.0f128 , TOL_PRECISE ) ;
257
- assert_approx_eq ! ( ( -0.0f128 ) . floor( ) , -0.0f128 , TOL_PRECISE ) ;
258
- assert_approx_eq ! ( ( -1.0f128 ) . floor( ) , -1.0f128 , TOL_PRECISE ) ;
259
- assert_approx_eq ! ( ( -1.3f128 ) . floor( ) , -2.0f128 , TOL_PRECISE ) ;
260
- assert_approx_eq ! ( ( -1.5f128 ) . floor( ) , -2.0f128 , TOL_PRECISE ) ;
261
- assert_approx_eq ! ( ( -1.7f128 ) . floor( ) , -2.0f128 , TOL_PRECISE ) ;
252
+ assert_eq ! ( 1.0f128 . floor( ) , 1.0f128 ) ;
253
+ assert_eq ! ( 1.3f128 . floor( ) , 1.0f128 ) ;
254
+ assert_eq ! ( 1.5f128 . floor( ) , 1.0f128 ) ;
255
+ assert_eq ! ( 1.7f128 . floor( ) , 1.0f128 ) ;
256
+ assert_eq ! ( 0.0f128 . floor( ) , 0.0f128 ) ;
257
+ assert_eq ! ( ( -0.0f128 ) . floor( ) , -0.0f128 ) ;
258
+ assert_eq ! ( ( -1.0f128 ) . floor( ) , -1.0f128 ) ;
259
+ assert_eq ! ( ( -1.3f128 ) . floor( ) , -2.0f128 ) ;
260
+ assert_eq ! ( ( -1.5f128 ) . floor( ) , -2.0f128 ) ;
261
+ assert_eq ! ( ( -1.7f128 ) . floor( ) , -2.0f128 ) ;
262
262
}
263
263
264
264
#[ test]
265
265
#[ cfg( not( miri) ) ]
266
266
#[ cfg( target_has_reliable_f128_math) ]
267
267
fn test_ceil ( ) {
268
- assert_approx_eq ! ( 1.0f128 . ceil( ) , 1.0f128 , TOL_PRECISE ) ;
269
- assert_approx_eq ! ( 1.3f128 . ceil( ) , 2.0f128 , TOL_PRECISE ) ;
270
- assert_approx_eq ! ( 1.5f128 . ceil( ) , 2.0f128 , TOL_PRECISE ) ;
271
- assert_approx_eq ! ( 1.7f128 . ceil( ) , 2.0f128 , TOL_PRECISE ) ;
272
- assert_approx_eq ! ( 0.0f128 . ceil( ) , 0.0f128 , TOL_PRECISE ) ;
273
- assert_approx_eq ! ( ( -0.0f128 ) . ceil( ) , -0.0f128 , TOL_PRECISE ) ;
274
- assert_approx_eq ! ( ( -1.0f128 ) . ceil( ) , -1.0f128 , TOL_PRECISE ) ;
275
- assert_approx_eq ! ( ( -1.3f128 ) . ceil( ) , -1.0f128 , TOL_PRECISE ) ;
276
- assert_approx_eq ! ( ( -1.5f128 ) . ceil( ) , -1.0f128 , TOL_PRECISE ) ;
277
- assert_approx_eq ! ( ( -1.7f128 ) . ceil( ) , -1.0f128 , TOL_PRECISE ) ;
268
+ assert_eq ! ( 1.0f128 . ceil( ) , 1.0f128 ) ;
269
+ assert_eq ! ( 1.3f128 . ceil( ) , 2.0f128 ) ;
270
+ assert_eq ! ( 1.5f128 . ceil( ) , 2.0f128 ) ;
271
+ assert_eq ! ( 1.7f128 . ceil( ) , 2.0f128 ) ;
272
+ assert_eq ! ( 0.0f128 . ceil( ) , 0.0f128 ) ;
273
+ assert_eq ! ( ( -0.0f128 ) . ceil( ) , -0.0f128 ) ;
274
+ assert_eq ! ( ( -1.0f128 ) . ceil( ) , -1.0f128 ) ;
275
+ assert_eq ! ( ( -1.3f128 ) . ceil( ) , -1.0f128 ) ;
276
+ assert_eq ! ( ( -1.5f128 ) . ceil( ) , -1.0f128 ) ;
277
+ assert_eq ! ( ( -1.7f128 ) . ceil( ) , -1.0f128 ) ;
278
278
}
279
279
280
280
#[ test]
281
281
#[ cfg( not( miri) ) ]
282
282
#[ cfg( target_has_reliable_f128_math) ]
283
283
fn test_round ( ) {
284
- assert_approx_eq ! ( 2.5f128 . round( ) , 3.0f128 , TOL_PRECISE ) ;
285
- assert_approx_eq ! ( 1.0f128 . round( ) , 1.0f128 , TOL_PRECISE ) ;
286
- assert_approx_eq ! ( 1.3f128 . round( ) , 1.0f128 , TOL_PRECISE ) ;
287
- assert_approx_eq ! ( 1.5f128 . round( ) , 2.0f128 , TOL_PRECISE ) ;
288
- assert_approx_eq ! ( 1.7f128 . round( ) , 2.0f128 , TOL_PRECISE ) ;
289
- assert_approx_eq ! ( 0.0f128 . round( ) , 0.0f128 , TOL_PRECISE ) ;
290
- assert_approx_eq ! ( ( -0.0f128 ) . round( ) , -0.0f128 , TOL_PRECISE ) ;
291
- assert_approx_eq ! ( ( -1.0f128 ) . round( ) , -1.0f128 , TOL_PRECISE ) ;
292
- assert_approx_eq ! ( ( -1.3f128 ) . round( ) , -1.0f128 , TOL_PRECISE ) ;
293
- assert_approx_eq ! ( ( -1.5f128 ) . round( ) , -2.0f128 , TOL_PRECISE ) ;
294
- assert_approx_eq ! ( ( -1.7f128 ) . round( ) , -2.0f128 , TOL_PRECISE ) ;
284
+ assert_eq ! ( 2.5f128 . round( ) , 3.0f128 ) ;
285
+ assert_eq ! ( 1.0f128 . round( ) , 1.0f128 ) ;
286
+ assert_eq ! ( 1.3f128 . round( ) , 1.0f128 ) ;
287
+ assert_eq ! ( 1.5f128 . round( ) , 2.0f128 ) ;
288
+ assert_eq ! ( 1.7f128 . round( ) , 2.0f128 ) ;
289
+ assert_eq ! ( 0.0f128 . round( ) , 0.0f128 ) ;
290
+ assert_eq ! ( ( -0.0f128 ) . round( ) , -0.0f128 ) ;
291
+ assert_eq ! ( ( -1.0f128 ) . round( ) , -1.0f128 ) ;
292
+ assert_eq ! ( ( -1.3f128 ) . round( ) , -1.0f128 ) ;
293
+ assert_eq ! ( ( -1.5f128 ) . round( ) , -2.0f128 ) ;
294
+ assert_eq ! ( ( -1.7f128 ) . round( ) , -2.0f128 ) ;
295
295
}
296
296
297
297
#[ test]
298
298
#[ cfg( not( miri) ) ]
299
299
#[ cfg( target_has_reliable_f128_math) ]
300
300
fn test_round_ties_even ( ) {
301
- assert_approx_eq ! ( 2.5f128 . round_ties_even( ) , 2.0f128 , TOL_PRECISE ) ;
302
- assert_approx_eq ! ( 1.0f128 . round_ties_even( ) , 1.0f128 , TOL_PRECISE ) ;
303
- assert_approx_eq ! ( 1.3f128 . round_ties_even( ) , 1.0f128 , TOL_PRECISE ) ;
304
- assert_approx_eq ! ( 1.5f128 . round_ties_even( ) , 2.0f128 , TOL_PRECISE ) ;
305
- assert_approx_eq ! ( 1.7f128 . round_ties_even( ) , 2.0f128 , TOL_PRECISE ) ;
306
- assert_approx_eq ! ( 0.0f128 . round_ties_even( ) , 0.0f128 , TOL_PRECISE ) ;
307
- assert_approx_eq ! ( ( -0.0f128 ) . round_ties_even( ) , -0.0f128 , TOL_PRECISE ) ;
308
- assert_approx_eq ! ( ( -1.0f128 ) . round_ties_even( ) , -1.0f128 , TOL_PRECISE ) ;
309
- assert_approx_eq ! ( ( -1.3f128 ) . round_ties_even( ) , -1.0f128 , TOL_PRECISE ) ;
310
- assert_approx_eq ! ( ( -1.5f128 ) . round_ties_even( ) , -2.0f128 , TOL_PRECISE ) ;
311
- assert_approx_eq ! ( ( -1.7f128 ) . round_ties_even( ) , -2.0f128 , TOL_PRECISE ) ;
301
+ assert_eq ! ( 2.5f128 . round_ties_even( ) , 2.0f128 ) ;
302
+ assert_eq ! ( 1.0f128 . round_ties_even( ) , 1.0f128 ) ;
303
+ assert_eq ! ( 1.3f128 . round_ties_even( ) , 1.0f128 ) ;
304
+ assert_eq ! ( 1.5f128 . round_ties_even( ) , 2.0f128 ) ;
305
+ assert_eq ! ( 1.7f128 . round_ties_even( ) , 2.0f128 ) ;
306
+ assert_eq ! ( 0.0f128 . round_ties_even( ) , 0.0f128 ) ;
307
+ assert_eq ! ( ( -0.0f128 ) . round_ties_even( ) , -0.0f128 ) ;
308
+ assert_eq ! ( ( -1.0f128 ) . round_ties_even( ) , -1.0f128 ) ;
309
+ assert_eq ! ( ( -1.3f128 ) . round_ties_even( ) , -1.0f128 ) ;
310
+ assert_eq ! ( ( -1.5f128 ) . round_ties_even( ) , -2.0f128 ) ;
311
+ assert_eq ! ( ( -1.7f128 ) . round_ties_even( ) , -2.0f128 ) ;
312
312
}
313
313
314
314
#[ test]
315
315
#[ cfg( not( miri) ) ]
316
316
#[ cfg( target_has_reliable_f128_math) ]
317
317
fn test_trunc ( ) {
318
- assert_approx_eq ! ( 1.0f128 . trunc( ) , 1.0f128 , TOL_PRECISE ) ;
319
- assert_approx_eq ! ( 1.3f128 . trunc( ) , 1.0f128 , TOL_PRECISE ) ;
320
- assert_approx_eq ! ( 1.5f128 . trunc( ) , 1.0f128 , TOL_PRECISE ) ;
321
- assert_approx_eq ! ( 1.7f128 . trunc( ) , 1.0f128 , TOL_PRECISE ) ;
322
- assert_approx_eq ! ( 0.0f128 . trunc( ) , 0.0f128 , TOL_PRECISE ) ;
323
- assert_approx_eq ! ( ( -0.0f128 ) . trunc( ) , -0.0f128 , TOL_PRECISE ) ;
324
- assert_approx_eq ! ( ( -1.0f128 ) . trunc( ) , -1.0f128 , TOL_PRECISE ) ;
325
- assert_approx_eq ! ( ( -1.3f128 ) . trunc( ) , -1.0f128 , TOL_PRECISE ) ;
326
- assert_approx_eq ! ( ( -1.5f128 ) . trunc( ) , -1.0f128 , TOL_PRECISE ) ;
327
- assert_approx_eq ! ( ( -1.7f128 ) . trunc( ) , -1.0f128 , TOL_PRECISE ) ;
318
+ assert_eq ! ( 1.0f128 . trunc( ) , 1.0f128 ) ;
319
+ assert_eq ! ( 1.3f128 . trunc( ) , 1.0f128 ) ;
320
+ assert_eq ! ( 1.5f128 . trunc( ) , 1.0f128 ) ;
321
+ assert_eq ! ( 1.7f128 . trunc( ) , 1.0f128 ) ;
322
+ assert_eq ! ( 0.0f128 . trunc( ) , 0.0f128 ) ;
323
+ assert_eq ! ( ( -0.0f128 ) . trunc( ) , -0.0f128 ) ;
324
+ assert_eq ! ( ( -1.0f128 ) . trunc( ) , -1.0f128 ) ;
325
+ assert_eq ! ( ( -1.3f128 ) . trunc( ) , -1.0f128 ) ;
326
+ assert_eq ! ( ( -1.5f128 ) . trunc( ) , -1.0f128 ) ;
327
+ assert_eq ! ( ( -1.7f128 ) . trunc( ) , -1.0f128 ) ;
328
328
}
329
329
330
330
#[ test]
331
331
#[ cfg( not( miri) ) ]
332
332
#[ cfg( target_has_reliable_f128_math) ]
333
333
fn test_fract ( ) {
334
- assert_approx_eq ! ( 1.0f128 . fract( ) , 0.0f128 , TOL_PRECISE ) ;
335
- assert_approx_eq ! ( 1.3f128 . fract( ) , 0.3f128 , TOL_PRECISE ) ;
336
- assert_approx_eq ! ( 1.5f128 . fract( ) , 0.5f128 , TOL_PRECISE ) ;
337
- assert_approx_eq ! ( 1.7f128 . fract( ) , 0.7f128 , TOL_PRECISE ) ;
338
- assert_approx_eq ! ( 0.0f128 . fract( ) , 0.0f128 , TOL_PRECISE ) ;
339
- assert_approx_eq ! ( ( -0.0f128 ) . fract( ) , -0.0f128 , TOL_PRECISE ) ;
340
- assert_approx_eq ! ( ( -1.0f128 ) . fract( ) , -0.0f128 , TOL_PRECISE ) ;
341
- assert_approx_eq ! ( ( -1.3f128 ) . fract( ) , -0.3f128 , TOL_PRECISE ) ;
342
- assert_approx_eq ! ( ( -1.5f128 ) . fract( ) , -0.5f128 , TOL_PRECISE ) ;
343
- assert_approx_eq ! ( ( -1.7f128 ) . fract( ) , -0.7f128 , TOL_PRECISE ) ;
334
+ assert_eq ! ( 1.0f128 . fract( ) , 0.0f128 ) ;
335
+ assert_eq ! ( 1.3f128 . fract( ) , 0.300000000000000000000000000000000039f128 ) ;
336
+ assert_eq ! ( 1.5f128 . fract( ) , 0.5f128 ) ;
337
+ assert_eq ! ( 1.7f128 . fract( ) , 0.7f128 ) ;
338
+ assert_eq ! ( 0.0f128 . fract( ) , 0.0f128 ) ;
339
+ assert_eq ! ( ( -0.0f128 ) . fract( ) , -0.0f128 ) ;
340
+ assert_eq ! ( ( -1.0f128 ) . fract( ) , -0.0f128 ) ;
341
+ assert_eq ! ( ( -1.3f128 ) . fract( ) , -0.300000000000000000000000000000000039f128 ) ;
342
+ assert_eq ! ( ( -1.5f128 ) . fract( ) , -0.5f128 ) ;
343
+ assert_eq ! ( ( -1.7f128 ) . fract( ) , -0.699999999999999999999999999999999961f128 ) ;
344
344
}
345
345
346
346
#[ test]
@@ -451,10 +451,10 @@ fn test_mul_add() {
451
451
let nan: f128 = f128:: NAN ;
452
452
let inf: f128 = f128:: INFINITY ;
453
453
let neg_inf: f128 = f128:: NEG_INFINITY ;
454
- assert_approx_eq ! ( 12.3f128 . mul_add( 4.5 , 6.7 ) , 62.05 , TOL_PRECISE ) ;
455
- assert_approx_eq ! ( ( -12.3f128 ) . mul_add( -4.5 , -6.7 ) , 48.65 , TOL_PRECISE ) ;
456
- assert_approx_eq ! ( 0.0f128 . mul_add( 8.9 , 1.2 ) , 1.2 , TOL_PRECISE ) ;
457
- assert_approx_eq ! ( 3.4f128 . mul_add( -0.0 , 5.6 ) , 5.6 , TOL_PRECISE ) ;
454
+ assert_eq ! ( 12.3f128 . mul_add( 4.5 , 6.7 ) , 62.0500000000000000000000000000000037 ) ;
455
+ assert_eq ! ( ( -12.3f128 ) . mul_add( -4.5 , -6.7 ) , 48.6500000000000000000000000000000049 ) ;
456
+ assert_eq ! ( 0.0f128 . mul_add( 8.9 , 1.2 ) , 1.2 ) ;
457
+ assert_eq ! ( 3.4f128 . mul_add( -0.0 , 5.6 ) , 5.6 ) ;
458
458
assert ! ( nan. mul_add( 7.8 , 9.0 ) . is_nan( ) ) ;
459
459
assert_eq ! ( inf. mul_add( 7.8 , 9.0 ) , inf) ;
460
460
assert_eq ! ( neg_inf. mul_add( 7.8 , 9.0 ) , neg_inf) ;
@@ -550,10 +550,10 @@ fn test_float_bits_conv() {
550
550
assert_eq ! ( ( 12.5f128 ) . to_bits( ) , 0x40029000000000000000000000000000 ) ;
551
551
assert_eq ! ( ( 1337 f128) . to_bits( ) , 0x40094e40000000000000000000000000 ) ;
552
552
assert_eq ! ( ( -14.25f128 ) . to_bits( ) , 0xc002c800000000000000000000000000 ) ;
553
- assert_approx_eq ! ( f128:: from_bits( 0x3fff0000000000000000000000000000 ) , 1.0 , TOL_PRECISE ) ;
554
- assert_approx_eq ! ( f128:: from_bits( 0x40029000000000000000000000000000 ) , 12.5 , TOL_PRECISE ) ;
555
- assert_approx_eq ! ( f128:: from_bits( 0x40094e40000000000000000000000000 ) , 1337.0 , TOL_PRECISE ) ;
556
- assert_approx_eq ! ( f128:: from_bits( 0xc002c800000000000000000000000000 ) , -14.25 , TOL_PRECISE ) ;
553
+ assert_eq ! ( f128:: from_bits( 0x3fff0000000000000000000000000000 ) , 1.0 ) ;
554
+ assert_eq ! ( f128:: from_bits( 0x40029000000000000000000000000000 ) , 12.5 ) ;
555
+ assert_eq ! ( f128:: from_bits( 0x40094e40000000000000000000000000 ) , 1337.0 ) ;
556
+ assert_eq ! ( f128:: from_bits( 0xc002c800000000000000000000000000 ) , -14.25 ) ;
557
557
558
558
// Check that NaNs roundtrip their bits regardless of signaling-ness
559
559
// 0xA is 0b1010; 0x5 is 0b0101 -- so these two together clobbers all the mantissa bits
0 commit comments