On 2017-02-23 13:55, Ray Hamel wrote:
> C99, C++11 and later introduced standardized fixed-width integer types such
> as int32_t provided in the headers stdint.h/cstdint and inttypes.h/cinttypes.
> However, although the float and double data types conventionally are
> implemented with, respectively, IEC 559 binary32 and binary64 format and
> semantics, and long double as a typedef of double, this is not specified by
> the standard.
>
> There is therefore a need for floating-point types with well-defined format
> and semantics, which could be provided in existing headers such as cfloat or
> cmath, or a new header perhaps called float, stdfloat or floattypes.
This seems reasonable to me at least. Please however name them e.g.
float32_t, for consistency:
int, short, long -> intN_t
float, double -> floatN_t
Given the int types are in cstdint, I guess the float types should be in
cstdfloat. This suggests however that you should talk to WG14 first...
Certainly the _fast variations make sense. I'm not sure how practical
the others are. Possibly _ieee754 makes sense to the extent that these
can either exist if floating point uses IEEE 754, or not exist
otherwise. Do non-IEEE compilers have a way of declaring an IEEE float
even if plain `float` is something else? For similar reasons, I'm not
sure if _trap, etc. variants are possible.
If you're going to have _fast, you should probably consider having
_least, also, especially if you have float80 variants, since a platform
might have float_least80_t -> float128_t but not have float80_t.
--
Matthew