Quantcast
Channel: which one is faster 5+5+5+5+5 or 5*5? - Stack Overflow
Browsing all 9 articles
Browse latest View live

Answer by Neil Coffey for which one is faster 5+5+5+5+5 or 5*5?

There are at least two questions here: the performance of the underlying operations, and what the compiler does. (In fact, what both the Java-to-bytecode compiler and the JIT compiler do.)Firstly, the...

View Article



Answer by Dirk for which one is faster 5+5+5+5+5 or 5*5?

It all depends on the environment you are using:Which compiler? Is it a good one, then it compiles it to constants.What's the rest of the program code? If the result is not used, it both compiles to...

View Article

Answer by Andreas Dolk for which one is faster 5+5+5+5+5 or 5*5?

We should compare time complexity. The function is f1(n) = n * c, the equivalent f2(n) = Sum[1->n] c.The complexity for multiplication is O(1) (constant time, one calculation for any n), the...

View Article

Answer by Clyde Lobo for which one is faster 5+5+5+5+5 or 5*5?

I guess Addition is faster than multiplication, because (as far as i know) all multiplications are treated as additionsAdded :read here for some explanation

View Article

Answer by gabuzo for which one is faster 5+5+5+5+5 or 5*5?

In your case is does not change anything. Let's compile:public class Toto { public static void main(String[] args) { int a = 5 + 5 + 5 + 5 + 5; int b = 5 * 5; }}and check the decompilation...

View Article


Answer by Ishu for which one is faster 5+5+5+5+5 or 5*5?

It depends on compiler because each compiler having different mechanism for this some using left shift operation or some uses another mechanism.But in many cases addition is faster than multiplication.

View Article

Answer by fortran for which one is faster 5+5+5+5+5 or 5*5?

Both are constant expressions, so they will be simplified to int a = 25;int b = 25;at compile time (100% sure, even toy compilers do this, as it is one of the simplest optimisations possible).In the...

View Article

Answer by Oliver Charlesworth for which one is faster 5+5+5+5+5 or 5*5?

It is platform (and compiler) dependent. If you need to know, then measure it. It's unlikely that you'll be in a situation where you need to know.However, in both your examples, these will be evaluated...

View Article


which one is faster 5+5+5+5+5 or 5*5?

I don't know how to ask but just want to ask. help me to tag it please. Anyway, my friend asked me a question that which one is faster in Javaint a = 5 + 5 + 5 + 5 + 5orint b = 5 * 5 ?Is it language...

View Article

Browsing all 9 articles
Browse latest View live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>