About this question
Hard · systems · Quant Developer interview question · floating-point, systems, numerical-analysis, c++
Maintaining an exact internal state of Profit and Loss (PnL) is critical, yet standard floating-point addition is not associative due to rounding errors. This lack of precision can lead to catastrophic cancellation when aggregating small fees or profits against large notional positions, requiring numerically stable summation algorithms to ensure deterministic results. Task Implement the PnLCalculator class to accurately compute the cumulative Net PnL from a stream of trades. You must implement