Which is more processor-intensive?

  • Thread starter iScience
  • Start date
In summary, both operations of dividing a big number by a smaller number and dividing a big number by a big number are equally process intensive. The type of division (integer or floating point) used does not significantly affect the time it takes. The compiler is also smarter at optimizing these calculations than manual efforts. The speed of the division also depends on the processor and its division algorithm. Using a library like libGMP can help with performing calculations with big numbers.
  • #1
iScience
466
5
What's more process intensive:

5465411784154564 / 3

or

5465411784154564 / 5746845218

ie a big number / small number or a big number / big number?

does it matter if I want to take the modulus instead?

------------------

EDIT:

Accidentally messed up my title, if a moderator could change it that'd be great
Thanks!
 
Technology news on Phys.org
  • #2
iScience said:
Accidentally messed up my title
Fixed...
 
  • #3
iScience said:
What's more process intensive:

5465411784154564 / 3

or

5465411784154564 / 5746845218

ie a big number / small number or a big number / big number?
My guess is that both operations are equally expensive in terms of processor cycles. When you have arithmetic operations like this, you need to think about the types that could be used. The dividend (number being divided) is too large to fit in 32 bits (an int or long in C), but would fit into 64 bits. In your examples, the dividend and both divisors are integer values, so integer division could be performed, but the result will be an integer.

If you want a precise answer, floating point division could be used, but neither a 32-bit floating point type (a float in C) nor a 64-bit floating point type (a double in C) would be able to hold all of the digits, so the answers wouldn't be that precise.
iScience said:
does it matter if I want to take the modulus instead?
Same concerns as above.
iScience said:
------------------

EDIT:

Accidentally messed up my title, if a moderator could change it that'd be great
Thanks!
 
  • #4
Both calculations will take the exact same amount of time.

Don't worry about optimizing things like math of plain data types, optimization of algorithms is always a better use of your time, any time savings at the bit-manipulation level is usually negligible.

Secondly, the compiler is usually much smarter than you when it comes to optimizing this sort of thing. The proper use of registers and L1 cache makes a difference several orders of magnitude above what you'd save by nitpicking POD math.

For example:
Code:
int x = y * 320;
can be converted into assembly in two ways

Code:
mov [y] ax
mul ax 320
mov ax [x]

Code:
mov [y] ax
mov bx ax
shr ax 8
shr bx 6
add ax bx
mov ax [x]
The compiler knows that the second is actually faster and will compile it that way for you.
 
Last edited:
  • #5
The answers above are true for many 64 bit CPUs and a 64 bit integer data type.
Usually way more critical is if the values you want to process are in a fast processor cache or need to be fetched from slower memory.

Otherwise it really depends on the processor used (and it's division algorithm), or if you use a type like BigInteger in Java on their actual implementation/algorithm too.

For example if it was implemented using Euclidian Division (which it's usually not, because that would be way too slow), then division by 3 would be slower than by the bigger number (because more iterations with substractions needed).

Depending on the processor/algorithm, both the result of the division and the remainder (result of modulo) might be available at the same time without increased cost, that is why C++ offers std::div:
http://www.cplusplus.com/reference/cstdlib/div/

If you are interested in algorithms for computing with big numbers, have a look i.e. at the libGMP (The GNU Multiple Precision Arithmetic Library):
https://gmplib.org/
 
  • #7
Dominik Tugend said:
[...]
For example if it was implemented using Euclidian Division (which it's usually not, because that would be way too slow), then division by 3 would be slower than by the bigger number (because more iterations with substractions needed).

That should have been Euclidian division by substraction, I can't edit it in anymore though, sorry for that mistake by me.
 

1. Which is more processor-intensive: graphics or calculations?

The answer to this question depends on the specific task at hand. Generally, graphics require more processing power because they involve rendering images and animations, which require complex calculations. However, certain calculations, such as those used in scientific simulations, can also be extremely processor-intensive.

2. Is a higher clock speed always better for processor-intensive tasks?

No, a higher clock speed does not always equate to better performance for processor-intensive tasks. Other factors such as the number of cores and the efficiency of the processor's architecture also play a significant role in determining overall processing power.

3. How does the type of processor affect its ability to handle processor-intensive tasks?

The type of processor can greatly impact its ability to handle processor-intensive tasks. For example, a graphics processing unit (GPU) is designed specifically for handling graphics and can outperform a central processing unit (CPU) in this area. On the other hand, a CPU is better suited for general-purpose computing tasks.

4. Can certain software or programs be more processor-intensive than others?

Yes, certain software or programs can be more processor-intensive than others. This is often determined by the specific tasks the software or program is designed to perform. For example, video editing software will likely be more processor-intensive than a basic text editor.

5. How can I optimize my computer for processor-intensive tasks?

There are a few ways to optimize your computer for processor-intensive tasks. One way is to make sure your computer has enough RAM to handle the specific task at hand. Another way is to close any unnecessary programs or processes running in the background. Additionally, choosing a computer with a higher-performing processor can also improve its ability to handle processor-intensive tasks.

Similar threads

Replies
6
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
7
Views
338
Replies
20
Views
2K
  • Science Fiction and Fantasy Media
Replies
0
Views
981
  • Programming and Computer Science
Replies
15
Views
1K
  • Sci-Fi Writing and World Building
Replies
9
Views
1K
  • Programming and Computer Science
Replies
1
Views
2K
Replies
3
Views
839
Replies
3
Views
946
Back
Top