How do cpus divide




















Connect and share knowledge within a single location that is structured and easy to search. I have searched hard in google but haven't got satisfactory results. Division algorithms in digital designs can be divided into two main categories.

Slow division and fast division. I suggest you read up on how binary addition and subtraction work if you are not yet familiar with these concepts. The simplest slow methods all work in the following way: Subtract the denominator from the numerator. Do this recursively with the result of each subtraction until the remainder is less than the denominator.

The amount of iterations is the integer quotient, and the amount left over is the remainder. Thus the answer is 2 with a remainder of 1. To make this answer a bit more relevant, here is some background. Binary subtraction via addition of the negative is performed e. This is accomplished by using its two's complement. Each binary number is added using a series of full adders:.

While the slower method of division is easy to understand, it requires repetitive iterations. There exist various "fast" algorithms, but they all rely on estimation. Hardware for floating point division is part of a logic unit that also does multiplication; there is a multiplier hardware module available. Interestingly, the old Pentium divide bug very newsworthy in was caused by a printing error that made faulty reciprocal-table values for step 4. There are very different methods for division, depending on the numbers to be handled.

For integers, the shift-and-subtract method given by others will work fine. For floating point numbers, however, it may be quicker to first compute the reciprocal of the denominator and then multiply that times your numerator.

Computation of the reciprocal of the denominator is not so bad; it is done by refining successive approximations. This converges quadratically, so you double the digits of precision on each improvement. Your initial guess is 0. You compute 0. Your adjusted guess is 0. Already pretty close! Repeat the process, and you get 0. There are some shortcuts. In floating point, you can extract powers of ten or powers of two, depending on the number base of your machine.

Once the computer can add and simulate subtraction, it can simulate multiplying and dividing. To multiply 6 times 7, the computer actually adds 6 together seven times and produces To divide 42 by 7, the computer subtracts 7 from 42 well, it adds the negative of 7 to 42 until it reaches zero and counts the number of times 6 it took to reach zero, like this:.

The computer represents numbers in a manner similar to characters. As Table 3. Once numbers reach a certain limit to be exact , the computer will use more than one byte to represent the number, taking as many memory locations as it needs to represent the number.

After it is taught to add, subtract, multiply, and divide, the computer can then perform any math necessary as long as a program is supplied to direct it. To see an example of what goes on at the bit level, follow this example to see what happens when you ask the computer to subtract 65 from The result should be zero and, as you can see from the following steps, that is exactly what the result is at the binary level.

That is, the binary representation for the letter A is , and the binary number for 65 is also The computer knows by the context of how your programs use the memory location whether the value is the letter A or the number This example shows that binary 65 plus binary negative 65 equals zero as it should.

The good thing about all this binary arithmetic is that you don't have to understand a bit of it pun intended to be an expert programmer. Nevertheless, the more you know about what is going on under the hood, the better you will understand how programming languages work and the faster you will master new ones by seeing similarities between them. I would like to receive exclusive offers and hear about products from InformIT and its family of brands.

I can unsubscribe at any time. Pearson Education, Inc. This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies. To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:.

For inquiries and questions, we collect the inquiry or question, together with name, contact details email address, phone number and mailing address and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes. Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites.

Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing.

Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information informit. On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information.

However, these communications are not promotional in nature. We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form. Pearson automatically collects log data to help ensure the delivery, availability and security of this site.

We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Viewed 17k times. Peter Cordes k 39 39 gold badges silver badges bronze badges. Joan Venge Joan Venge k gold badges silver badges bronze badges.

You will have to ask an electronics engineer, it is a circuit design problem. Creating a hardware multiplier is pretty easy, a hardware divider is not. Practical divider circuits are iterative and therefore take longer. Ask at electronics. Wikipedia cf. This seems to be regardless of the type.

Who is volunteering to do a benchmark? In short: quotient estimate and correction steps. You're right that multiplication breaks down into multiple additions and division breaks down into multiple subtractions.

The difference is that the additions in multiplication can be done in parallel, whereas in division, you can't do the next subtraction until finish the previous one and do a comparison.

So a hardware multiplier will exploit this inherent parallelism by computing and summing up many sub-products simultaneously at the cost of increased area real-estate. Division does not have this luxury. Show 3 more comments. Active Oldest Votes. TheCodeArtist Lior Kogan Lior Kogan Add a comment. Lets consider a long multiplication of two n bit binary numbers.

We can add the numbers in groups rather than sequentially. Until the final step we can add three numbers to produce two rather than adding two to produce one.



0コメント

  • 1000 / 1000