source:
CIVL/examples/analysis/abs.c@
5833ea9
| Last change on this file since 5833ea9 was e4cc4f5, checked in by , 11 years ago | |
|---|---|
|
|
| File size: 538 bytes | |
| Rev | Line | |
|---|---|---|
| [b1b88d8] | 1 | #include <stdlib.h> |
| [9570bc1] | 2 | #include <civlc.cvh> |
| [b1b88d8] | 3 | |
| [e4cc4f5] | 4 | $input int k; |
| [9570bc1] | 5 | $input int x; |
| 6 | $input int y; | |
| 7 | $input int z; | |
| 8 | $assume(x<0); | |
| 9 | $assume(y>0); | |
| [e4cc4f5] | 10 | $assume(k!=0); |
| [b1b88d8] | 11 | void main(){ |
| 12 | int a = 9; | |
| 13 | ||
| [9570bc1] | 14 | a=abs(0); // 0 |
| 15 | a=abs(x); // - | |
| 16 | a=abs(y); // + | |
| 17 | a=abs(z); // * | |
| [e4cc4f5] | 18 | a=abs(k); |
| [9570bc1] | 19 | a=abs(x*y*z); // * |
| [e4cc4f5] | 20 | a=abs(x*y*k); |
| [9570bc1] | 21 | a=abs(x*y); // - |
| 22 | $assert(x*y<=0); | |
| 23 | ||
| 24 | a=abs(x%y); //+ | |
| 25 | $assert(x%y>=0); | |
| 26 | ||
| 27 | a=abs((-x)%y); // + | |
| 28 | $assert((-x)%y>=0); | |
| [e4cc4f5] | 29 | |
| 30 | a=abs(z%2-1); | |
| 31 | $assert((z%2-1)<=0); | |
| 32 | a=abs(z%2-2); | |
| 33 | $assert((z%2-2)<0); | |
| [b1b88d8] | 34 | } |
Note:
See TracBrowser
for help on using the repository browser.
