File: modulo.c

package info (click to toggle)
why 2.26%2Bdfsg-2%2Bsqueeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 19,796 kB
  • ctags: 19,175
  • sloc: ml: 115,078; java: 9,253; ansic: 4,757; makefile: 1,350; sh: 485; lisp: 3
file content (13 lines) | stat: -rw-r--r-- 278 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
/*@ requires 
  @   x >= 0 && y > 0
  @ ensures 
  @   0 <= \result < y &&
  @   \exists int d; x == d * y + \result
  @*/
int math_mod(int x, int y) { 
  /*@ invariant 0 <= x && \exists int d; \old(x) == d * y + x
    @ variant x
    @*/
  while (x >= y) x -= y;
  return x;
}