Discussion Overview
The discussion revolves around returning complex numbers from functions in C, specifically addressing issues related to data types and adherence to the C99 standard. Participants explore various methods to handle complex numbers in their code, including the use of structs and the built-in complex number support in C99.
Discussion Character
- Technical explanation
- Debate/contested
Main Points Raised
- One participant expresses difficulty in returning complex numbers from functions and questions the appropriate function type to use.
- Another participant suggests using a pair or struct with two doubles to represent complex numbers.
- A different participant recommends using the complex numbers defined in the C99 standard, proposing to declare the function as double complex.
- A participant shares a code snippet and expresses uncertainty about the variable types and function return types related to complex numbers.
- One participant questions how the type of the rn[] array is set, asking if it should be double _Complex.
- Another participant critiques the code for not following C99 standards and points out that the return statement is incorrectly placed within a loop, although later clarifications indicate it is actually outside the loop.
- Concerns are raised about compiling code with warnings, emphasizing that a correct program should not compile with warnings.
- There is a discussion about the legality of variable scope in C99, with one participant clarifying that declaring a variable within a for loop is valid.
Areas of Agreement / Disagreement
Participants express differing views on the best approach to handle complex numbers in C, with no consensus reached on a single solution. Some participants advocate for using C99's built-in complex number support, while others suggest alternative methods like structs.
Contextual Notes
There are unresolved questions regarding the correct implementation of complex number handling in C, including potential issues with data types and adherence to standards. The discussion highlights the importance of compiling code without warnings and following established programming practices.