Quantcast
Channel: Dafny: An Automatic Program Verifier for Functional Correctness
Viewing all articles
Browse latest Browse all 1106

Created Unassigned: Bug in BigRational implementation [148]

$
0
0
There is a bug in BigRational implementation as the following example, which produces `False` as output, shows:

```
method Main()
{
var zero : real := 0.0;
var fifteen : real := 15.0;

assert zero <= fifteen;

print zero <= fifteen, "\n";
}
```

The problem comes from *BigRational.CompareTo* in the Dafny prelude. As a solution, I propose to change the method like this:

```
public int CompareTo(BigRational that) {
BigInteger aa, bb, dd;
Normalize(this, that, out aa, out bb, out dd);
return aa.CompareTo(bb);
}
```

The sign comparisons are wrong but they are also unnecessary because *Normalize* respects the signs.

Viewing all articles
Browse latest Browse all 1106

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>