# Math: which is faster?

Hi All !

I 'have an indicator that gives me the average value between HIGH and LOW values, and I need the whole difference between them.

Which is faster to perform in all ticks: multiply the average by 2 or simply subtract the LOW from the HIGH value?

All of them are DOUBLE type.

Thanks!

AliceRioBR: I 'have an indicator that gives me the average value between HIGH and LOW values, and I need the whole difference between them. Which is faster to perform in all ticks: multiply the average by 2 or simply subtract the LOW from the HIGH value? All of them are DOUBLE type.

Usually subtraction is faster than multiplication, and multiplication is faster then division, but in modern CPUs it may have very little impact. But I personally prefer sticking to the old ways.

```double
mid_value   = ( high + low ) * 0.5,
delta_value =   high - low;```

Fernando Carreiro # :Usually subtraction is faster than multiplication, and multiplication is faster then division, but in modern CPUs in may have very little impact. But I personally prefer sticking to the old ways.

Thank you Fernando!
Goodnight.

Fernando Carreiro #:Usually subtraction is faster than multiplication, and multiplication is faster then division, but in modern CPUs in may have very little impact. But I personally prefer sticking to the old ways.
Here is a document that shows the Performance Impact of different operations. It's a bit technical, more for the enthusiastic coder.

But basically ADD SUB and MUL are the fastest instructions for math operations.

Dominik Christian Egert #:
Here is a document that shows the Performance Impact of different operations. It's a bit technical, more for the enthusiastic coder.

But basically ADD SUB and MUL are the fastest instructions for math operations.

Great !!
It reminds me of the time I programmed in ASM (x86) with MASM. And I only did not program now with x64 because I really did find a good IDE. I tried some in VS2022, but they are really very poor) to try with NASM.