Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c++
Subject: Re: 1.0 / 0.0
Date: Sun, 16 Jan 2022 12:40:40 -0800
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <86h7a3tnw7.fsf@linuxsc.com>
References:
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="66ee21d996f56235c8cdb5e1ea47e716"; logging-data="1917"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19kpX+kuiL4+XexxltU5zxaAsp2qQ88k2c="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:sqq5ZFf4tRI7jrMJYqhhYHorpk0= sha1:0OIgyinI0S3/cZ/X99MVgPI1hIY=
Xref: csiph.com comp.lang.c++:82787
Juha Nieminen writes:
> Manfred wrote:
>
>> The irony is that this is probably one of those examples where C beats
>> C++ - good ol' HUGE_VALF or INFINITE would raise no question at all!
>
> What is the type of INFINITE? What if you want it as one of the other two
> floating point types? (Is casting defined in this case?)
I haven't checked the C++ standard, but in C (assuming a suitable
infinite value is available) the macro INFINITY expands to a
constant expression of type float, with an infinite value. Any
value of type float must have corresponding values in type double
and long double, and converting a float value to double or long
double must produce the corresponding value in the target type.
(Converting includes but is not limited to cast operations.)