|
| 1 | +(set-logic FP) |
| 2 | + |
| 3 | +(assert (not (and |
| 4 | + |
| 5 | + ; round up |
| 6 | + (= (fp.roundToIntegral roundTowardPositive (_ NaN 11 53)) (_ NaN 11 53)) |
| 7 | + (= (fp.roundToIntegral roundTowardPositive (_ +oo 11 53)) (_ +oo 11 53)) |
| 8 | + (= (fp.roundToIntegral roundTowardPositive (_ -oo 11 53)) (_ -oo 11 53)) |
| 9 | + REQUIRE(ieee_floatt::from_double(up, 1).round_to_integral() == 1); |
| 10 | + REQUIRE(ieee_floatt::from_double(up, 0.1).round_to_integral() == 1); |
| 11 | + REQUIRE(ieee_floatt::from_double(up, -0.1).round_to_integral() == -0.0); |
| 12 | + REQUIRE(ieee_floatt::from_double(up, 10.1).round_to_integral() == 11); |
| 13 | + REQUIRE(ieee_floatt::from_double(up, -10.1).round_to_integral() == -10); |
| 14 | + REQUIRE(ieee_floatt::from_double(up, dmax).round_to_integral() == dmax); |
| 15 | + |
| 16 | + ; round down |
| 17 | + (= (fp.roundToIntegral roundTowardNegative (_ NaN 11 53)) (_ NaN 11 53)) |
| 18 | + (= (fp.roundToIntegral roundTowardNegative (_ +oo 11 53)) (_ +oo 11 53)) |
| 19 | + (= (fp.roundToIntegral roundTowardNegative (_ -oo 11 53)) (_ -oo 11 53)) |
| 20 | + REQUIRE(ieee_floatt::from_double(down, 0).round_to_integral() == 0); |
| 21 | + REQUIRE(ieee_floatt::from_double(down, -0.0).round_to_integral() == -0.0); |
| 22 | + REQUIRE(ieee_floatt::from_double(down, 1).round_to_integral() == 1); |
| 23 | + REQUIRE(ieee_floatt::from_double(down, 0.1).round_to_integral() == 0); |
| 24 | + REQUIRE(ieee_floatt::from_double(down, -0.1).round_to_integral() == -1); |
| 25 | + REQUIRE(ieee_floatt::from_double(down, 10.1).round_to_integral() == 10); |
| 26 | + REQUIRE(ieee_floatt::from_double(down, -10.1).round_to_integral() == -11); |
| 27 | + REQUIRE(ieee_floatt::from_double(down, 0x1.0p+52).round_to_integral() == 0x1.0p+52); |
| 28 | + REQUIRE(ieee_floatt::from_double(down, dmax).round_to_integral() == dmax); |
| 29 | + |
| 30 | + ; round to nearest ties to even |
| 31 | + (= (fp.roundToIntegral roundNearestTiesToEven (_ NaN 11 53)) (_ NaN 11 53)) |
| 32 | + (= (fp.roundToIntegral roundNearestTiesToEven (_ +oo 11 53)) (_ +oo 11 53)) |
| 33 | + (= (fp.roundToIntegral roundNearestTiesToEven (_ -oo 11 53)) (_ -oo 11 53)) |
| 34 | + REQUIRE(ieee_floatt::from_double(even, 0).round_to_integral() == 0); |
| 35 | + REQUIRE(ieee_floatt::from_double(even, -0.0).round_to_integral() == -0.0); |
| 36 | + REQUIRE(ieee_floatt::from_double(even, 1).round_to_integral() == 1); |
| 37 | + REQUIRE(ieee_floatt::from_double(even, 0.1).round_to_integral() == 0); |
| 38 | + REQUIRE(ieee_floatt::from_double(even, -0.1).round_to_integral() == -0.0); |
| 39 | + REQUIRE(ieee_floatt::from_double(even, 10.1).round_to_integral() == 10); |
| 40 | + REQUIRE(ieee_floatt::from_double(even, -10.1).round_to_integral() == -10); |
| 41 | + REQUIRE(ieee_floatt::from_double(even, 0x1.0p+52).round_to_integral() == 0x1.0p+52); |
| 42 | + REQUIRE(ieee_floatt::from_double(even, dmax).round_to_integral() == dmax); |
| 43 | + |
| 44 | + ; round to zero |
| 45 | + (= (fp.roundToIntegral roundTowardZero (_ NaN 11 53)) (_ NaN 11 53)) |
| 46 | + (= (fp.roundToIntegral roundTowardZero (_ +oo 11 53)) (_ +oo 11 53)) |
| 47 | + (= (fp.roundToIntegral roundTowardZero (_ -oo 11 53)) (_ -oo 11 53)) |
| 48 | + REQUIRE(ieee_floatt::from_double(zero, 0).round_to_integral() == 0); |
| 49 | + REQUIRE(ieee_floatt::from_double(zero, -0.0).round_to_integral() == -0.0); |
| 50 | + REQUIRE(ieee_floatt::from_double(zero, 1).round_to_integral() == 1); |
| 51 | + REQUIRE(ieee_floatt::from_double(zero, 0.1).round_to_integral() == 0); |
| 52 | + REQUIRE(ieee_floatt::from_double(zero, -0.1).round_to_integral() == -0.0); |
| 53 | + REQUIRE(ieee_floatt::from_double(zero, 10.1).round_to_integral() == 10); |
| 54 | + REQUIRE(ieee_floatt::from_double(zero, -10.1).round_to_integral() == -10); |
| 55 | + REQUIRE(ieee_floatt::from_double(zero, 0x1.0p+52).round_to_integral() == 0x1.0p+52); |
| 56 | + REQUIRE(ieee_floatt::from_double(zero, dmax).round_to_integral() == dmax); |
| 57 | +))) |
| 58 | + |
| 59 | +; should be unsat |
| 60 | +(check-sat) |
0 commit comments