Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Are variables of the same type with bigger values slower?

If I create variable with the int32_t type with the value of 1 for example and another variable with the same type but the value will be the int32 max value, will computations be faster in expressions with the first variable rather than the second?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

In the comments, you asked

So, theoretically the bigger value variable could be faster than the smaller one depending on computations?

which generalizes the question to

  • Could computation time differ between inputs with value 1 and inputs with value MAX_INT?

For many elementary operations such as addition and bit-wise OR, the answer is No.

For arbitrary computation, the answer is Most definitely yes, unless you are very careful to prevent it.

The possibility of correlation between input values and time is quite significant in the information security community. Good search terms: "timing side channel" and "constant-time implementation".

A related concern is whether the power consumption of the arithmetic circuitry correlates to input values, even when the time is constant.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading