File tree Expand file tree Collapse file tree 3 files changed +73
-0
lines changed
benchmarks/verification/valid Expand file tree Collapse file tree 3 files changed +73
-0
lines changed Original file line number Diff line number Diff line change 1+ import stainless .math ._
2+
3+ object FPFledging {
4+ def test1 (x : Double ): Unit = {
5+ assert(Double .longBitsToDouble(Double .doubleToRawLongBits(x)) == x)
6+ }
7+
8+ def test2 (x : Long ): Unit = {
9+ Double .longBitsToDoublePost(x)
10+ assert(Double .doubleToRawLongBits(Double .longBitsToDouble(x)) == x)
11+ }
12+
13+ def test3 (x : Float ): Unit = {
14+ assert(Float .intBitsToFloat(Float .floatToRawIntBits(x)) == x)
15+ }
16+
17+ def test4 (x : Int ): Unit = {
18+ Float .intBitsToFloatPost(x)
19+ assert(Float .floatToRawIntBits(Float .intBitsToFloat(x)) == x)
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ package stainless
2+ package math
3+
4+ import lang .StaticChecks ._
5+ import annotation ._
6+
7+ @ library
8+ case class Double (@ extern @ pure private val value : scala.Double ) extends AnyVal
9+
10+ @ library
11+ object Double {
12+ @ extern @ pure
13+ def longBitsToDouble (l : Long ): Double = {
14+ Double (java.lang.Double .longBitsToDouble(l))
15+ }
16+
17+ @ extern @ pure
18+ def longBitsToDoublePost (l : Long ): Unit = {
19+ ()
20+ } ensuring (_ => doubleToRawLongBits(longBitsToDouble(l)) == l)
21+
22+ @ extern @ pure
23+ def doubleToRawLongBits (d : Double ): Long = {
24+ java.lang.Double .doubleToRawLongBits(d.value)
25+ } ensuring (res => longBitsToDouble(res) == d)
26+ }
Original file line number Diff line number Diff line change 1+ package stainless
2+ package math
3+
4+ import lang .StaticChecks ._
5+ import annotation ._
6+
7+ @ library
8+ case class Float (@ extern @ pure private val value : scala.Float ) extends AnyVal
9+
10+ @ library
11+ object Float {
12+ @ extern @ pure
13+ def intBitsToFloat (i : Int ): Float = {
14+ Float (java.lang.Float .intBitsToFloat(i))
15+ }
16+
17+ @ extern @ pure
18+ def intBitsToFloatPost (i : Int ): Unit = {
19+ ()
20+ } ensuring (_ => floatToRawIntBits(intBitsToFloat(i)) == i)
21+
22+ @ extern @ pure
23+ def floatToRawIntBits (d : Float ): Int = {
24+ java.lang.Float .floatToRawIntBits(d.value)
25+ } ensuring (res => intBitsToFloat(res) == d)
26+ }
You can’t perform that action at this time.
0 commit comments