Re: [hatari-devel] Removing SDL use for byte order checks / conversions

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,
Do what you think is right. My earliest use of M_PI started with Borland C in 1993 August 20. I would have looked for some standard definition of pi. I subsequently found M_PI to be ubiquitously available in the following years. It now appears that people won't touch math constants; necessitating that you make you own.
Ideally the constants header file should be:
 - unconditional (un-defines previous definitions that pollute the namespace)
 - mathematically correct ( #define PI 3.14159 /* use more digits if necessary (minimum 23 digits) */ )
 - unencumbered by pedantic programming tradition ( #define PI 3.14159L /* error: foolish suffix L */)
 - mathematically aesthetic ( 2*PI*radius    PI/180.0  /* does this look good? */ )
Sincerely,
David Savinkoff


On Thu, Oct 6, 2022 at 1:07 AM Thomas Huth <th.huth@xxxxxxxxx> wrote:
On 05/10/2022 19.17, Eero Tamminen wrote:
>
> Defines should be upper case, and more than 2 letters I think.
>
> IMHO better solution is just moving
> the "ifndef M_PI, define M_PI" to a common header, after "include <math.h>".
>
> On 5.10.2022 0.55, David Savinkoff wrote:
>> Dear Sirs:
>>
>> An unused M_PI define in src/falcon/dsp_core.c is the only M_PI in
>> Hatari that is not my fault.

I think we can remove that #define in dsp_core.c since it is not used anymore.

>> I have come to the conclusion that the entirety of computer science
>> has had decades to find a way of representing pi and has failed.
>>    Thus, the correct way of defining pi on a computer in C is as follows:
>> #define pi 3.14159265358979323846264338327950 /* use more digits if needed
>> */
>> Note that pi is lower case because pi is fundamentally more important than
>> C convention.

Uff, I didn't expect my one-line patch to #include <SDL_stdinc.h> to cause
so much discussion ;-) ... anyway, if you all are really that unhappy about
SDL_stdinc.h (which always #defines M_PI), I think I'd rather prefer Eero's
suggestion to always define M_PI if it is not available in math.h yet. M_PI
should be available on *most* systems in math.h, so it is still some kind of
default naming and we should not diverge from that in Hatari to make, I think.

  Thomas




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/