4 ms·
It really doesn't matter, the compiler will generate the same code (gcc -S at least does generate the same assembler output for both pieces of code; see: https:
by reidrac 10y ago
It really doesn't matter, the compiler will generate the same code (gcc -S at least does generate the same assembler output for both pieces of code; see: https://gist.github.com/reidrac/afb89b29228a243954bd51281c39ee88 https://gist.github.com/reidrac/afb89b29228a243954bd51281c39...).
I guess looking at the definition: https://en.wikipedia.org/wiki/Absolute_value#Real_numbers https://en.wikipedia.org/wiki/Absolute_value#Real_numbers I would say `( j >= 0 ) ? j : -j` is more accurate, although in practical terms is the same result.