# Thread: div operator proof

1. ## div operator proof

Don't tell me the whole answer...I just need a hint, I guess.

I'm supposed to prove that a div b is non-negative when a and b have the same sign, and non-positive when they have different signs.

Am I on the right track with this (this is just the first case I'm supposed to consider)?

Case 1. Assume a ≥ 0 and b < 0. rb ≥ 0, so r ≤ 0.

Then a div b = q = (a - r) / b

Since r ≤ 0 and a ≥ 0, a div b can be rewritten as ( |a|+ |r| ) / b

Since b < 0, a div b can be rewritten as (-1)( |a|+ |r| ) / |b|

Since ( |a|+ |r| ) / |b| is non-negative, the value a div b is non-positive in this case.

2. ## Re: div operator proof

Hey euphony.

Are these vectors a and b vector-valued functions? If so what constraints do they have (i.e. to make them positive)?

3. ## Re: div operator proof

Hi,
What is the div operator? Do you mean integer division in a programming language? If so, the most common definition (Java, C and Python) is for integers a and b with b not 0, a div b = sgn(a)*sgn(b)*floor(|a|/|b|). That is, a div b is truncated toward 0. Examples 5 div 2 = 2 but -5 div 2 is -2, not floor(-5/2) = -3. If this is what you mean by div, there's really nothing to prove??

4. ## Re: div operator proof

a div b means the quotient of a divided by b. So floor(a/b).
It seems obvious that something negative divided by something positive will equal something negative and so forth, but I'm not sure how I would prove that without already assuming it's true in the proof.

5. ## Re: div operator proof

Have you already proved, or can you use, the fact that the product of two numbers with the same sign is positive and the product of two numbers with opposite sign is negative?

Is so, I suggest a "proof by contradiction". Suppose a and b are both positive and x= a div b is negative. You can write a= bx+ r where $0\le r< 1$ (do you understand that?). Now b is at least 1 so if x is negative, bx is at least -1.

6. ## Re: div operator proof

Have you already proved, or can you use, the fact that the product of two numbers with the same sign is positive and the product of two numbers with opposite sign is negative?
The only relevant thing I can find that we proved is (-a)(-b) = ab. That doesn't assume that a and b have the same sign, but could I use it?