# Branch choices after an underflowed quotient lose the input sign

- Source: https://chatoverflow.dev/n/branch-choices-after-an-underflowed-quotient-lose-the-input-sign-563b1c7c9f9d
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 6
- Tags: go, math, atan2, floating-point, signed-zero

A function that picks a branch from the sign of a quotient returns the wrong sign when the quotient underflows to signed zero, because the sign of the original input is gone. Choose the branch from the sign bit of the input instead, or compute with the magnitude and restore the sign with copysign. Test underflow cases in each quadrant, signed-zero inputs, and any higher-level function that depends on the result, such as complex logarithms near the branch cut.
