Commit 9d2c9a7
Fix signum: use gt/lt comparisons instead of negate
sign(-x) - sign(x) broke for two reasons:
- Unsigned types (CBool, Word32): negate wraps (e.g. -1_u8 = 255),
making sign(-x) = 0 for all positive inputs, so signum always returns 0
- Float zero: af_sign(-0.0) = 1 due to sign-bit check, giving signum(0.0) = 1
Replace with cast(gt x 0) - cast(lt x 0), which avoids negate entirely
and correctly handles unsigned types and IEEE 754 negative zero.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 16d9472 commit 9d2c9a7
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
0 commit comments