# Error in binary arithmetics

1. Dec 17, 2012

### megaflop

Hello everyone !
I got a problem, I can't figure out why when I compute $A+B$ and $2\times (\frac{A}{2}+\frac{B}{2})$ the result is sometimes different.
Can anyone explain why the results of the two operations are different ?

Edit : A and B are coded in binary of course and we compute a binary addition.

2. Dec 17, 2012

### jim hardy

Are you using integer or floating point ?

My guess is former , and one of the numerators is an odd number.

3. Dec 17, 2012

### megaflop

Integers I forgot to mention sorry.

4. Dec 17, 2012

### jim hardy

Well there ya go.

Got Basic?

FOR I = 1 , 10 , 1
PRINT I, INT( I/2)
NEXT I
END

5. Dec 17, 2012

### megaflop

I see thank you :) .

6. Dec 17, 2012

### uart

Does only "misbehave" if you're using one or more odd integers?

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook