Skip to content

Fix division by zero in log2 for complex inputs (mappers.cc)#47

Open
AADARSHPUROHIT466 wants to merge 1 commit intognu-octave:defaultfrom
AADARSHPUROHIT466:fix-log2-zero-case
Open

Fix division by zero in log2 for complex inputs (mappers.cc)#47
AADARSHPUROHIT466 wants to merge 1 commit intognu-octave:defaultfrom
AADARSHPUROHIT466:fix-log2-zero-case

Conversation

@AADARSHPUROHIT466
Copy link
Contributor

@AADARSHPUROHIT466 AADARSHPUROHIT466 commented Feb 13, 2026

The original implementation of log2(const Complex& x, int& exp) could
cause division by zero when x = (0,0).

This patch adds explicit handling for the zero case, returning -infinity
as the appropriate representation of log(0).

Additionally, a finiteness check ensures we don't propagate NaN or Inf
values unexpectedly, improving numerical stability.

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments