FNZ platform calculations may require integer division for normalized portfolio values without relying on language division helpers. Implement integer division using bit shifts and subtraction only.
Given two signed 32-bit integers, dividend and divisor, return the quotient truncated toward zero. Do not use /, //, %, *, **, divmod, or equivalent library functions. You may use comparisons, addition, subtraction, and bit shifts.
If the result is outside the signed 32-bit range, clamp it to 2147483647 or -2147483648. The divisor is guaranteed to be nonzero.
dividend and divisor, each in [-2147483648, 2147483647].dividend / divisor, clamped to the signed 32-bit range.def divide(dividend, divisor):