Register to reply

Error in binary arithmetics

by megaflop
Tags: arithmetics, binary, error
Share this thread:
megaflop
#1
Dec17-12, 02:03 PM
P: 10
Hello everyone !
I got a problem, I can't figure out why when I compute [itex]A+B[/itex] and [itex]2\times (\frac{A}{2}+\frac{B}{2})[/itex] 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.
Phys.Org News Partner Engineering news on Phys.org
Future phones to use blood and speech to monitor HIV, stress, nutrition
Neuron circuit may enable pitch perception applications
Quasi-distributed temperature sensors from draw-tower fabrication technology
jim hardy
#2
Dec17-12, 02:12 PM
Sci Advisor
PF Gold
jim hardy's Avatar
P: 3,632
Are you using integer or floating point ?

My guess is former , and one of the numerators is an odd number.
megaflop
#3
Dec17-12, 02:14 PM
P: 10
Integers I forgot to mention sorry.

jim hardy
#4
Dec17-12, 02:24 PM
Sci Advisor
PF Gold
jim hardy's Avatar
P: 3,632
Error in binary arithmetics

Well there ya go.

Got Basic?

FOR I = 1 , 10 , 1
PRINT I, INT( I/2)
NEXT I
END
megaflop
#5
Dec17-12, 02:32 PM
P: 10
Quote Quote by jim hardy View Post
Well there ya go.

Got Basic?

FOR I = 1 , 10 , 1
PRINT I, INT( I/2)
NEXT I
END
I see thank you :) .
uart
#6
Dec17-12, 09:38 PM
Sci Advisor
P: 2,751
Quote Quote by megaflop View Post
Integers I forgot to mention sorry.
Does only "misbehave" if you're using one or more odd integers?


Register to reply

Related Discussions
Arithmetics and algebra, what/ which is the main concept? Set Theory, Logic, Probability, Statistics 22
Arithmetics in Z Linear & Abstract Algebra 3
Binary Search Error Programming & Computer Science 0
A question on modular arithmetics Precalculus Mathematics Homework 5
Tertiary Arithmetics General Math 1