Your question is Divide Without Operators. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
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):