| Deutsch English Français Italiano |
|
<86h6cyal3m.fsf@linuxsc.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder9.news.weretis.net!3.eu.feeder.erje.net!feeder.erje.net!news.in-chemnitz.de!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups: comp.lang.c
Subject: Re: question about nullptr
Date: Tue, 09 Jul 2024 03:57:49 -0700
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <86h6cyal3m.fsf@linuxsc.com>
References: <v6bavg$3pu5i$1@dont-email.me> <20240706054641.175@kylheku.com> <v6bfi1$3qn4u$1@dont-email.me> <l9ciO.7$cr5e.2@fx05.iad> <877cdyuq0f.fsf@bsb.me.uk> <2ckiO.19403$7Ej.4487@fx46.iad> <87plrpt4du.fsf@bsb.me.uk> <9bCiO.7108$sXW9.3805@fx41.iad> <877cdwu9s1.fsf@nosuchdomain.example.com> <20240708222804.00001654@yahoo.com> <20240708194600.781@kylheku.com> <20240709110019.00004d6d@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Tue, 09 Jul 2024 12:57:50 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="4404f50b61bba69374b6468dfb9554fc";
logging-data="1431426"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+zjwFaJvV8LDiS1qyxwl+E8cu3OWbpj84="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:/9KWElFjr4OoBHpo1E+F7YlO3Cg=
sha1:oQTEathwkV/HOaV2RKFkWhcm6hI=
Bytes: 3017
Michael S <already5chosen@yahoo.com> writes:
> 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.
Normally I would leave off the final 0 and just write 42.
Alternatively, a floating-point 42 can be written 42e0,
which stands out a little more than just using a trailing
dot.