@@ -410,7 +410,10 @@ public void specialValueFunctionsFrom32Bits2() throws SolverException, Interrupt
410
410
requireBitvectors ();
411
411
requireFPToBitvector ();
412
412
413
- FloatingPointFormula x = fpmgr .makeVariable ("x32" , singlePrecType );
413
+ final FloatingPointFormula x = fpmgr .makeVariable ("x32" , singlePrecType );
414
+ final BitvectorFormula signBit = bvmgr .extract (fpmgr .toIeeeBitvector (x ), 31 , 31 );
415
+ final BitvectorFormula exponent = bvmgr .extract (fpmgr .toIeeeBitvector (x ), 30 , 23 );
416
+ final BitvectorFormula mantissa = bvmgr .extract (fpmgr .toIeeeBitvector (x ), 22 , 0 );
414
417
415
418
assertThatFormula (fpmgr .isInfinity (x ))
416
419
.isEquivalentTo (
@@ -427,49 +430,35 @@ public void specialValueFunctionsFrom32Bits2() throws SolverException, Interrupt
427
430
assertThatFormula (fpmgr .isNormal (x ))
428
431
.isEquivalentTo (
429
432
bmgr .and (
430
- bmgr .not (
431
- bvmgr .equal (
432
- bvmgr .extract (fpmgr .toIeeeBitvector (x ), 30 , 23 ),
433
- bvmgr .makeBitvector (8 , 0 ))),
434
- bmgr .not (
435
- bvmgr .equal (
436
- bvmgr .extract (fpmgr .toIeeeBitvector (x ), 30 , 23 ),
437
- bvmgr .makeBitvector (8 , -1 )))));
433
+ bmgr .not (bvmgr .equal (exponent , bvmgr .makeBitvector (8 , 0 ))),
434
+ bmgr .not (bvmgr .equal (exponent , bvmgr .makeBitvector (8 , -1 )))));
438
435
439
436
assertThatFormula (fpmgr .isSubnormal (x ))
440
437
.isEquivalentTo (
441
438
bmgr .and (
442
- bvmgr .equal (
443
- bvmgr .extract (fpmgr .toIeeeBitvector (x ), 30 , 23 ), bvmgr .makeBitvector (8 , 0 )),
444
- bmgr .not (
445
- bvmgr .equal (
446
- bvmgr .extract (fpmgr .toIeeeBitvector (x ), 22 , 0 ),
447
- bvmgr .makeBitvector (23 , 0 )))));
439
+ bvmgr .equal (exponent , bvmgr .makeBitvector (8 , 0 )),
440
+ bmgr .not (bvmgr .equal (mantissa , bvmgr .makeBitvector (23 , 0 )))));
448
441
449
442
assertThatFormula (fpmgr .isNaN (x ))
450
443
.isEquivalentTo (
451
444
bmgr .and (
452
- bvmgr .equal (
453
- bvmgr .extract (fpmgr .toIeeeBitvector (x ), 30 , 23 ), bvmgr .makeBitvector (8 , -1 )),
454
- bmgr .not (
455
- bvmgr .equal (
456
- bvmgr .extract (fpmgr .toIeeeBitvector (x ), 22 , 0 ),
457
- bvmgr .makeBitvector (23 , 0 )))));
445
+ bvmgr .equal (exponent , bvmgr .makeBitvector (8 , -1 )),
446
+ bmgr .not (bvmgr .equal (mantissa , bvmgr .makeBitvector (23 , 0 )))));
458
447
459
448
assertThatFormula (fpmgr .isNegative (x ))
460
449
.isEquivalentTo (
461
- bmgr .and (
462
- bmgr .not (fpmgr .isNaN (x )),
463
- bvmgr .equal (
464
- bvmgr .extract (fpmgr .toIeeeBitvector (x ), 31 , 31 ), bvmgr .makeBitvector (1 , 1 ))));
450
+ bmgr .and (bmgr .not (fpmgr .isNaN (x )), bvmgr .equal (signBit , bvmgr .makeBitvector (1 , 1 ))));
465
451
}
466
452
467
453
@ Test
468
454
public void specialValueFunctionsFrom64Bits2 () throws SolverException , InterruptedException {
469
455
requireBitvectors ();
470
456
requireFPToBitvector ();
471
457
472
- FloatingPointFormula x = fpmgr .makeVariable ("x64" , doublePrecType );
458
+ final FloatingPointFormula x = fpmgr .makeVariable ("x64" , doublePrecType );
459
+ final BitvectorFormula signBit = bvmgr .extract (fpmgr .toIeeeBitvector (x ), 63 , 63 );
460
+ final BitvectorFormula exponent = bvmgr .extract (fpmgr .toIeeeBitvector (x ), 62 , 52 );
461
+ final BitvectorFormula mantissa = bvmgr .extract (fpmgr .toIeeeBitvector (x ), 51 , 0 );
473
462
474
463
assertThatFormula (fpmgr .isInfinity (x ))
475
464
.isEquivalentTo (
@@ -490,41 +479,24 @@ public void specialValueFunctionsFrom64Bits2() throws SolverException, Interrupt
490
479
assertThatFormula (fpmgr .isNormal (x ))
491
480
.isEquivalentTo (
492
481
bmgr .and (
493
- bmgr .not (
494
- bvmgr .equal (
495
- bvmgr .extract (fpmgr .toIeeeBitvector (x ), 62 , 52 ),
496
- bvmgr .makeBitvector (11 , 0 ))),
497
- bmgr .not (
498
- bvmgr .equal (
499
- bvmgr .extract (fpmgr .toIeeeBitvector (x ), 62 , 52 ),
500
- bvmgr .makeBitvector (11 , -1 )))));
482
+ bmgr .not (bvmgr .equal (exponent , bvmgr .makeBitvector (11 , 0 ))),
483
+ bmgr .not (bvmgr .equal (exponent , bvmgr .makeBitvector (11 , -1 )))));
501
484
502
485
assertThatFormula (fpmgr .isSubnormal (x ))
503
486
.isEquivalentTo (
504
487
bmgr .and (
505
- bvmgr .equal (
506
- bvmgr .extract (fpmgr .toIeeeBitvector (x ), 62 , 52 ), bvmgr .makeBitvector (11 , 0 )),
507
- bmgr .not (
508
- bvmgr .equal (
509
- bvmgr .extract (fpmgr .toIeeeBitvector (x ), 51 , 0 ),
510
- bvmgr .makeBitvector (52 , 0 )))));
488
+ bvmgr .equal (exponent , bvmgr .makeBitvector (11 , 0 )),
489
+ bmgr .not (bvmgr .equal (mantissa , bvmgr .makeBitvector (52 , 0 )))));
511
490
512
491
assertThatFormula (fpmgr .isNaN (x ))
513
492
.isEquivalentTo (
514
493
bmgr .and (
515
- bvmgr .equal (
516
- bvmgr .extract (fpmgr .toIeeeBitvector (x ), 62 , 52 ), bvmgr .makeBitvector (11 , -1 )),
517
- bmgr .not (
518
- bvmgr .equal (
519
- bvmgr .extract (fpmgr .toIeeeBitvector (x ), 51 , 0 ),
520
- bvmgr .makeBitvector (52 , 0 )))));
494
+ bvmgr .equal (exponent , bvmgr .makeBitvector (11 , -1 )),
495
+ bmgr .not (bvmgr .equal (mantissa , bvmgr .makeBitvector (52 , 0 )))));
521
496
522
497
assertThatFormula (fpmgr .isNegative (x ))
523
498
.isEquivalentTo (
524
- bmgr .and (
525
- bmgr .not (fpmgr .isNaN (x )),
526
- bvmgr .equal (
527
- bvmgr .extract (fpmgr .toIeeeBitvector (x ), 63 , 63 ), bvmgr .makeBitvector (1 , 1 ))));
499
+ bmgr .and (bmgr .not (fpmgr .isNaN (x )), bvmgr .equal (signBit , bvmgr .makeBitvector (1 , 1 ))));
528
500
}
529
501
530
502
@ Test
0 commit comments