Implementation details of ModMulFastConst function

In code ModMulFastConst function, according to the comments, the ModMulFastConst function comes from https://arxiv.org/pdf/1205.2926.pdf (Dave Harvey, FASTER ARITHMETIC FOR NUMBER-THEORETIC TRANSFORMS). The algorithm is described in lines 5-7 of Algorithm 2.
In the original paper,


Q ← ⌊W′T/β⌋
But in the code, NativeInt q = MultDHi(m_value, bInv.m_value) + 1;
Why add 1 at the end?

Q is a measure of how many p's did we overflow. Algorithm 2 approximates this value, potentially underestimating it by 1, while OpenFHE implementation overestimates it by 1.

In OpenFHE, Q is incremented by 1 to simplify the adjustment logic in Step 7. The comparison is done against 0, and the increment yprime + p is conditional, that is, not always executed.