0
$\begingroup$

how can I do a formal proof of the following description:

$a\;div\;b = \begin{cases} \lfloor \frac{a}{b} \rfloor &\text{ if }b>0\\ \lceil \frac{a}{b} \rceil &\text{ if }b<0 \end{cases}\\$

It seems pretty straight forward as $a$ div $b$ is defined as $q$ from the expression $a=q b + r$, where r has to be a positive integer smaller than b.

  • 0
    Thank you @Pambos; you're right. @Adeel - well I know what floor and ceil functions do, but even then it seems trivial that q has to be largest integer not greater than the quotient (if b>0) and the otherway around for b<0...2012-12-10

1 Answers 1

1

If $b\mid a$ is easy. So assume that $b\nmid a$.

Let $k$ be the largest integer that is smaller to $\dfrac{a}{b}$, i.e. $k$ is the integer with the property $k<\dfrac{a}{b}.
If $b>0$ then for $0 we have $a=kb+sb$ and $0 . Therefore $a \text{ div } b=k=\lfloor\dfrac{a}{b}\rfloor$.
If $b<0$ then for $0 we have $a=(k+1)b-sb$ and $0 <-sb. Therefore $a \text{ div } b=k+1=\lceil\dfrac{a}{b}\rceil$.