Division

In mathematics, division (÷) is an arithmetic elementary operation.

Multiplication

Multiplication is the mathematical operation of scaling one number by another

Expensive one number

Quality Example
More

"However in general one could expect that a division is a more expensive operation than a multiplication"

from question "Conditional tests in primality by trial division"

Constant compiler expensive

Quality Example
More expensive

"It will be much slower i don t have benchmarks but i would guess at least an order of magnitude maybe more decimal will not benefit from any hardware acceleration and arithmetic on it will require relatively expensive multiplication division by powers of 10 which is far more expensive than multiplication and dividion by powers of 2 to match the exponent before addition subtraction and to bring the exponent back into range after multiplication division"

from question "When should I use double instead of decimal?"

"Usually division is a lot more expensive than multiplication but a smart compiler will often convert division by a compile-time constant to a multiplication anyway"

from question "What has a better performance: multiplication or division?"

Faster

"Most optimizing c compilers optimize it out to a multiplication operation which is much faster than division it can be done only if the divisor is constant though"

from question "Print decimal in 8086 emulator"

Normally more expensive

"This solution has the disadvantage that if the other factor is not constant the compiler and you can t reasonably avoid the division int_max n to be done at runtime and division is normally more expensive than multiplication"

from question "Check for int overflow in C++"

Integer gap relative

Quality Example
Slower

"The reason to do this is because even though there is an integer division instruction div idiv in the instruction set it s typically very slow several times slower than multiplication"

from question "How does the GCC implementation of modulo (%) work, and why does it not use the div instruction?"

"Hardware integer division is always slower than multiplication and the gap in the relative latencies of these instructions continues to widen"

from question "Fast Division and Modular operation for non two power numbers"

Fewer cycles means

Quality Example
Usually fewer

"Floating point multiplication usually takes fewer cycles than floating point division"

from question "Is multiplication faster than float division?"

Fewer

"It has to do with the fact that multiplication is itself done by means of binary shifts and additions - far fewer than with division"

from question "How to use right shift to avoid operator division"

Many more clock

"It is common knowledge that division takes many more clock cycles to compute than multiplication"

from question "Should I use multiplication or division for recurring floats?"

Slower operations support

Quality Example
Slower

"On many machines particularly those without hardware support for division division is a slower operation than multiplication so this approach can yield a considerable speedup"

from question "Calculating Reciprocals: n**(-1) or (1/n)?"

Slower hardware

"You always need to know the magic number here 0xaaaaaaab and the correct operations after the multiplication shifts and or additions in most cases and both is different depending on the number you want to divide by and both take too much cpu time to calculate them on the fly that would be slower than hardware division"

from question "What's the fastest way to divide an integer by 3?"

Typically slower

"Removing division operations by passing through the inverse into the shader is another useful tip as division is typically slower than multiplication"

from question "Optimization of HLSL shaders"

Higher precedence i.e

Quality Example
Higher precedence

"Since multiplication is of higher precedence than division"

from question "Decimal and mathematical operations"

"Does multiplication has higher precedence over division or it is other way round"

from question "Multiplication vs Division in C"

"Multiplication has higher precedence than division"

from question "Macro usage in C?"

"In some of the academic literature implied multiplication is interpreted as having higher precedence than division"

from question "Which has higher precedence in C -multiplication or division?"

Higher presedence

"I read that multiplication has has higher presedence than division"

from question "Multiplication and division: weird output in c"

Expensive cost someone

Quality Example
More expensive

"Division is always much more expensive than multiplication"

from question "Efficient Multiply/Divide of two 128-bit Integers on x86 (no 64-bit)"

"Division is a lot more expensive than multiplication"

from question "Implementing matrix vector multiplication in assembly"

"The reason for doing so is to reduce hardware cost as division is more expensive than multiplication"

from question "Generating lookup table for arctan computation"

Less expensive

"Multiplication is less expensive than division so"

from question "How to normalize a NumPy array to within a certain range?"

Always more expensive

"Recently someone suggested to me that division is always more expensive than multiplication"

from question "Benefits of multiplication rather than division"

Much more costly

"Knowing that a division is much more costly than a multiplication"

from question "Speeding up the code using numpy"

Much more

"Division is much more expensive than multiplication"

from question "Decrease in instructions retired after loop Unrolling"

Line time multiple

Quality Example
Cheaper

"Following advise i received multiplication is cheaper than division i revised one code line and interestingly enough 71.2 dropped to 1.7 but the if statement just below shot up to 64.8 â i just don t get it"

from question "Performance optimizing critical code in iOS app"

More time

"I have heard division takes more time then multiplication but beyond that i could not determine whether writing this in one line or multiple assignment lines was more efficient"

from question "Java Optimizing arithmetic and Assignment Operators for large input"

Worse addition latency

Quality Example
Worse

"Formally it means division cannot have a complexity worse than multiplication"

from question "Complexity of division"

Harder

"If you think back to grade school you ll recall that multiplication was harder than addition and division was harder than multiplication"

from question "Why is multiplying cheaper than dividing?"

Worse latency

"Division has worse latency than multiplication or addition by a factor of 2 to 4 on modern x86 cpus and worse throughput by a factor of 6 to 40"

from question "Floating point division vs floating point multiplication"

Modern cpus fast

Quality Example
Slower float

"On modern processors float division is a good order of magnitude slower than float multiplication when measured by reciprocal throughput"

from question "Fast approximate float division"

Heavier

"Division may be heavier than multiplication but a commenter pointed out that reciprocals are just as fast as multiplication on modern cpus in which case this isn t correct for your case so if you do have 1 x appearing somewhere inside a loop and more than once you can assist by caching the result inside the loop and then using y"

from question "Fast 1/X division (reciprocal)"

Faster slower integer

Quality Example
Faster integer

"According to this author integer multiplication can be 40 times faster than integer division"

from question "Most efficient way to calculate lexicographic index"

Slower

"The tostring should be slower than parse since division is generally slower than multiplication"

from question "Is it more efficient to compare ints and ints or strings and strings"

"In all other cases division appears to be several times slower than multiplication"

from question "What has a better performance: multiplication or division?"

"Division is per se slower than multiplication however i don t know the details"

from question "Why is float division slow?"

"Because division is often much slower than multiplication if performance is critical you might keep a table with powers of ten and their reciprocals"

from question "Java: convert float to double preserving decimal point precision"

"Division algorithms are slower than multiplication algorithms in most cases"

from question "Is Multiplying the Inverse Better or Worse?"

"Both works but division is generally slower than multiplication"

from question "Calculating prime numbers in python"

"Division is slower than multiplication due to some reasons"

from question "Will the compiler optimize division into multiplication"

"Is it possible that the division is six times slower than multiplication and"

from question "Float Operations Performance C++"

"Division is about 10 times slower than multiplication"

from question "Efficient Multiply/Divide of two 128-bit Integers on x86 (no 64-bit)"

Much slower

"I found out that integer division is much slower than multiplication unfortunately"

from question "Optimizing Fixed-Point Sqrt"

Typically faster

"I used multiplication for both operations because multiplication is typically faster than division"

from question "Rounding floats in processing.org"

Faster

"This because 1 x is simpler than y x and multiplication is faster than division"

from question "Calculating GFlops"

"As to why multiplication is faster than division and when the divisor is fixed this is a faster route"

from question "Why does GCC use multiplication by a strange number in implementing integer division?"

"Similar to pmg s solution but still faster because multiplication is faster than division -"

from question "Find the "string length" of an int"

"Division is faster for unint8 than multiplication in your case"

from question "NumPy performance: uint8 vs. float and multiplication vs. division?"

"Multiplication is usually significantly faster than division"

from question "Fast multiplication/division by 2 for floats and doubles (C/C++)"

"Multiplication is much faster than division"

from question "What is fastest x86-64 assembly-language divide algorithm for huge numbers?"

"On many processors integer multiplication is faster than integer division"

from question "Efficient (cycles wise) algorithm to compute modulo 25?"

"Division is about 20 faster than multiplication"

from question "Should I use multiplication or division?"

"Multiplication is usually faster than division"

from question "SIGABRT error for - https://www.codechef.com/problems/PRIME1"

"As hroptatyr mentioned the multiplication is quite fast and it s much faster than division"

from question "How can I use bit shifting to replace integer division?"

"Multiplication is faster than division"

from question "Is multiplication faster than float division?"

"Since you re resizing the window make sure to assign the w and h values not as numbers but as products or dynamic numbers multiplication is faster than division but you can also use division"

from question "Alpha Blending in SDL resets after resizing window"

"If the latter yes floating point multiplication is generally faster than division"

from question "A good way to do a fast divide in C++?"

"In usual programming practice one wouldn t bother and simply multiplying by the floating-point representation of 180 ï because multiplication is so much faster than division"

from question "Should I combine multiplication and division steps when working with floating point values?"

"Integer multiplication is much faster than division"

from question "Fast Euclidean division in C"

"For the division-to-multiplication case you are assuming that multiplication is faster than division"

from question "Would C# compiler or Jitter optimize these kinds of arithmetic operations?"

"First of all multiplication is faster than division"

from question "Is there a preferred way to order floating-point operands?"

Generally longer

"It s just as fast as going the opposite direction if not faster given that division generally takes longer than multiplication"

from question "Reverse factorial"

Faster then

"I would also suggest to replace terms like a l1 0.3e1 with as multiplication is faster then division"

from question "How can I improve performance via a high-level approach when implementing long equations in C++"

Others

Quality Example
Longer

"Why does division take so much longer than multiplication"

from question "Floating point division vs floating point multiplication"

"Division takes a lot longer than multiplication - just do it with pen and paper to see"

from question "Sort several arrays together and return the ranking number in the all-arrays combined score"

Worse

"So division is always a bit worse than multiplication"

from question "Polynomial evaluation accuracy, multiplication versus division"

"But since division is pretty expensive i think that this is even worse than 2 multiplication"

from question "Euler 11. There must be a better way than this"

More costly affair

"The intuition is that division is a more costly affair than multiplication"

from question "Fast lookup from floating point index into array"

Cheaper

"T is not very important as long as alpha is small otherwise you will run into some rather weird nyquist issues aliasing etc. and if you are working on a processor where multiplication is cheaper than division or fixed-point issues are important precalculate omega"

from question "Exponential Moving Average Sampled at Varying Times"

"I always thought a multiplication is computationally cheaper than a division"

from question "NumPy performance: uint8 vs. float and multiplication vs. division?"

"If a remains the same and b is changing say if your code is in a loop and it s clear that a does not change between two iterations for instance because it s a const variable then the original version can execute faster because multiplication is cheaper than division assuming the compiler moves the computation of 1 ."

from question "Reason for peculiar ordering of division and multiplication in C++"

More complicated

"For division things are a little more complicated than multiplication see"

from question "Big Integer arithmetic"

More accurate

"In fact if the intent is to divide by 22 10 or some other real value that isn t necessarily exactly representable in binary floating-point then half the times the multiplication is more accurate than the division because it happens by coincidence that the relative error for 1 x is less than the relative error for x"

from question "Should I use multiplication or division for recurring floats?"

Much simpler

"Division though is an iterative process in logic the implementations you see on educational sites verilog vhdl are simply doing the same thing we did with log division in grade school but like multiplication it is much simpler than grade school you pull down bits from the numerator in the long division until the number being checked against the denominator is equal to or larger basically the number can either go in only zero times or one times into the next number under test unlike decimal where it can be between 0 to 9 times"

from question "Which is harder: a modern Casio calculator in Assembler or division of real numbers in Verilog?"

Slower

"Which one is faster is indeed a cpu-specific issue or at least how much faster is cpu specific yes division is typically seen as slower than multiplication"

from question "Is Multiplying the Inverse Better or Worse?"

"Integer division is about an order of magnitude slower than multiplication on current cpus."

from question "Fast way to check if long integer is a cube (in Java)"

"According to stephen canon modern implementations favor taylor expansion over rational function approximation where division is much slower than multiplication"

from question "Definitions of sqrt, sin, cos, pow etc. in cmath"

"Division is slower than multiplication is generally - and definitely using regular expression matching is going to be slower than multiplication is.."

from question "JavaScript Math.round: Doesnt round object to 1 decimal"

"Division is generally on the order of 10x slower than multiplication on most processor families"

from question "Is division more expensive than multiplication in C++?"

Slower long

"If multiplication are o n 2 this is slower than long division for large numbers o n 2 vs o n 2 log n"

from question "Numeric division using BCD format"

Much slower

"On some machines division is much slower than multiplication but on most machines j multiplies and j divides will run a lot faster than 2 n-2 multiplication and one division"

from question "Why am I getting errors using the Lambda function?"

Costlier

"Well if it is a single calculation you wil hardly notice any difference but if you talk about millions of transaction then definitely division is costlier than multiplication"

from question "What has a better performance: multiplication or division?"

Much more complicated

"The cpu operation for float division is much more complicated than multiplication"

from question "Why is multiplying cheaper than dividing?"

Faster so

"Change the half to 0.5 and you should be golden for the math part also multiplication is faster so use it instead of division when possible"

from question "C++ printing a function's result?"

Faster

"I wonder why everybody missed that multiplication is much faster than division"

from question "How to check if an integer is a power of 3?"

"Multiplication is faster than division see fog s tables"

from question "What does clang's `-Ofast` option do in practical terms especially for any differences from gcc?"

"The double_unit stuff is how random actually does it internally because multiplication is faster than division see floating point division vs floating point multiplication"

from question "Using a random long to generate random doubles"

"In a 64 bit application this code will be a lot faster than in a 32 bit application in a 32 bit application multiplying two 64 bit numbers take 3 multiplication and 3 additions on 32 bit values - however it might be still faster than a division on a 32 bit machine"

from question "What's the fastest way to divide an integer by 3?"

"Floating point multiplication is faster than division so if speed is relevant"

from question "Source code to round floating point number"

"This can be a major clock-cycle saver since multiplication is often much faster than a division operation"

from question "Is shifting bits faster than multiplying and dividing in Java? .NET?"

"Here s one idea which uses one multiplication and one shift so it ll be faster than a division on most systems"

from question "Optimizing Division by Unknown Denominator Without Using Division Operator"

"As a rule of thumb multiplication is faster than division on all cpus"

from question "Reading assembly comparing multiplication vs division"

"I do not want to know when or if to use shift operators in my code i am interested in why multiplication is faster than shifting bits to the left whereas division is not"

from question "Differences in division and multiplication vs bit shifting"

Better

"If you are sure that a floating point multiplication is better than a floating point division then"

from question "Rearranging an equation"

Slower integer

"It is well known that integer division is slow operation typically several times slower than integer multiplication"

from question "Fast integer division in Java"

Usually slower

"If the numbers are huge dividing x by b might be betterâ division is usually slower than multiplication but getting out of the huge-number domain early might help more than avoiding division"

from question "Computes the logarithm of a number x relative to a base b.n other words"

Shorter

"I haven t benchmarked any of this code but just by examining the code you can see that using integers division by 2 is shorter than multiplication by 2"

from question "Should I use multiplication or division?"

More

"Or is there something about multiplication that is more convenient than division in programming"

from question "Calculating Reciprocals: n**(-1) or (1/n)?"

"Easiest way is to simply recognize that division is nothing more than the multiplication of the dividend y and the inverse of the divisor x"

from question "Fast approximate float division"

Much less

"Iirc floating-point multiplication is much less expensive than division so this might be faster than both"

from question "Efficiency of floating point division and checking values beforehand if eq"

Back to Home
Data comes from Stack Exchange with CC-BY-SA-3.0