Liste des Groupes | Revenir à cl c |
On Tue, 9 Jul 2024 02:49:49 -0000 (UTC)
Kaz Kylheku <643-408-1753@kylheku.com> wrote:
>On 2024-07-08, Michael S <already5chosen@yahoo.com> wrote:>On Sun, 07 Jul 2024 15:17:34 -0700
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>
I just about always use NULL, not 0, when I want a null pointer
constant. Similarly, I use '\0', not 0, when I want a null
character, 0.0 when I want a floating-point zero, and false when I
want a Boolean zero. I just like being explicit.
Pointer: I very rarely use NULL.
Character: I never use '\0'.
Floating point: I never use 0.0.
Never say never!
printf("%f\n", 0); // undefined behavior.
printf("%f\n", 0.0); // correct
>
Yes, but that's extremely rare that I want constant (except string
literal) as variable argument to printf().
If you're #define-ing a floating-point constant that has>
no fractional part, you should put that .0 there.
>
I am trying hard to avoid #define-ing floating-point constants.
In rare cases where it is not avoidable, most often the constant does
have fractional part. I am not sure what I would prefer when I can't
avoid #define-ing and the constant has no fractional part. Will I write
something like '#define ANSWER ((double)42)' or (42.0) ?
It depends on the mood of the minute.
Les messages affichés proviennent d'usenet.