About this question
Medium · low_latency · Quant Developer interview question · branchless, arithmetic-shift, abs, low_latency, bit-manipulation, pnl
In high-frequency trading, P&L calculations must be extremely fast, as they are performed billions of times per session. Conditional branches in tight loops, such as those in a naive abs(pnl) implementation, can cause costly CPU branch mispredictions. This problem explores a branchless technique using bitwise arithmetic to compute the absolute value of an integer, a critical optimization in low-latency systems. Task Implement the function branchless_abs(int64_t x) to compute the absolute value
Keep practicing