Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

Code style question: Multiplication vs. powers of 2 or 3

$
0
0

I have a colleague who insists on writing code such as this :

!-----calculate Grashof numbers --------------

grashm = G * betam * dt * (L*L*L) * (denm*denm) / (vism*vism) ! fluid mean

grashl = G * betal * dt * (L*L*L) * (denl*denl) / (visl*visl) ! liquid

grashg = G * betag * dt * (L*L*L) * (deng*deng) / (visg*visg) ! gas

 Compared to my usual practice, which would be this:

grashm = G * betam * dt * L**3 * denm**2 / vism**2 ! fluid mean

grashl = G * betal * dt * L**3 * denl**2 / visl**2 ! liquid

grashg = G * betag * dt * L**3 * deng**2 / visg**2 ! gas

What are the pros and cons here? Is there any chance one or the other of these will be faster in execution, assuming they are both compiled with full optimization?

Qolin


Viewing all articles
Browse latest Browse all 5691

Trending Articles



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