cplusplus / draft

C++ standards drafts
http://www.open-std.org/jtc1/sc22/wg21/
5.66k stars 748 forks source link

[basic.fundamental] p12 Saying that "range of representable values" is implementation-defined is helpful #5546

Open xmh0511 opened 2 years ago

xmh0511 commented 2 years ago

[basic.fundamental] p12 says

The value representation of floating-point types is implementation-defined.

For other integer types, we did not emphasize this point for them. Isn't the value representation for integer types also implementation-defined? Consider the impact for the value representation with the difference between big-endian and little-endian in a concrete environment, and assume the width for short int is always16.

short i = 2;
//  big-endian 00000000 00000010
// little-endian 00000010 00000000

The example wants to convey that saying the value representation is implementation-defined does not mean the range of representable values is implementation-defined too.

So, saying that the value representation of floating-point types is implementation-defined is not all that important here. It is not helpful for interpreting whether a floating-pointer type can represent positive infinity or not. As said in https://github.com/cplusplus/draft/issues/5407#issuecomment-1107394398, we consider the existence of these values for a floating-pointer type is implementation-defined, which means that we care more about the range of representable values. I think, change the above rule to that

The range of representable values for floating-pointer types is implementation-defined.

which is more helpful.

frederick-vs-ja commented 1 month ago

Isn't the value representation for integer types also implementation-defined?

This part is tracked in CWG2827. Representable range is made specified more detailedly via CWG2723, but the most negative/positive finite values are not yet said implementation-defined.

I'm not sure whether "The value representation of floating-point types is implementation-defined" already implies that "the meaning of each bit pattern of the value representation of a floating-point type is implementation-defined". If so, no change seems needed here.