OT: computer arithmetic question on integer division
Globe Trotter
itsme_410 at yahoo.com
Tue Jan 18 23:59:50 UTC 2005
Hi, thanks, to you and everybody!
My question is: how does a computer actually do it? When we are dividing a
number by a multiple of two, for example 5 = 101 divided by 2 = 10, then all we
do is shift the bit by the number of digits after the leading 1 in 2. So, 101
divided by 10 means drop the last 1 in the 101 so we get 10.
What happens if we divide 5= 101 by 3= 11? Anything similar?
No, this is not something for homework. In fact, I am not a computer scientist
but a statistician. I last turned in a homework assignment ten years ago....
I just was curious, and I thought entrepreneurial Fedora users would be the
best to ask!
Best wishes!
--- Andrea Giuliano <a.giuliano at iccu.sbn.it> wrote:
> I hope I understand your question right! Pardon me if I'm completely out
> of target.
>
> The only way I know to do divisions is repeating a subtraction until you
> get a null remainder. This is how mathematicians define integer
> division, if I'm not too much in error:
>
> "given integer A and B, there is a unique pair of integer Q and R such
> that 0<=R<B and A=B*Q+R"
>
> So you see that you only can get Q and R subtracting B from A until you
> get a non null remainder. This should work for positive or negative
> numbers, but it's easier to understand for positive numbers.
>
> Mmhhh, yes, it's not very clear, sorry.
>
> Globe Trotter wrote:
> > HI,
> >
> > Does anyone know how the computer *actually* does integer
> > division? I understand that with powers of 2, it just does bit
> > shifting, but what about other powers, do you know?
> >
> > (for example, 5/2 = 101/10 so shift the 101 by 1 and get 10, but how
> > does 5/3 work, lets say?)
> >
> > Thanks and best wishes!
> >
> >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Read only the mail you want - Yahoo! Mail SpamGuard.
> > http://promotions.yahoo.com/new_mail
> >
>
> --
> Andrea Giuliano, Ph. D.
> ICCU - Istituto Centrale per il Catalogo Unico
> Viale Castro Pretorio 105, Rome - ITALY
> Tel. +39064989509, Fax +39064059302
>
> --
> fedora-list mailing list
> fedora-list at redhat.com
> To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list
>
__________________________________
Do you Yahoo!?
Meet the all-new My Yahoo! - Try it today!
http://my.yahoo.com
More information about the users
mailing list