return time * 0.5;
// OR
return time / 2;
}
Benchmark it
there's only one way to find out: measure
if it's compiled you can check the ASM, the compiler might translate both to the same asm
Okay guys. Understood. I will use Godbolt Compiler Explorer, am I right?
I thought it's a popular tool to do that
it is, I just never had the need for it
* compiles to mulsd / compiles to divsd Related answers I found: https://stackoverflow.com/questions/71739078/why-is-divsd-not-much-slower-than-mulsd-in-this-benchmark https://stackoverflow.com/questions/4125033/floating-point-division-vs-floating-point-multiplication/45899202#45899202
Обсуждают сегодня