cplusplus / papers

ISO/IEC JTC1 SC22 WG21 paper scheduling and management
674 stars 18 forks source link

P3488 Floating-Point Excess Precision #2136

Open mattkretz opened 3 weeks ago

mattkretz commented 3 weeks ago

P3488R0 Floating-Point Excess Precision (Matthias Kretz)

mattkretz commented 3 weeks ago

This paper addresses #1584

mattkretz commented 1 week ago

P3488R0: Floating-Point Excess Precision

2024-11-19 SG6 Minutes

Chair: Matthias Kretz

Champion: Matthias Kretz

Polls

POLL: Constant expressions (not constant folding) may not use greater precision and range than the type. => Reproducibility in constant expressions. If you need more precision and range use std::float128_t in constant expressions.

SF F N A SA
4 2 0 0 0

# of Participants: 6 Outcome: Strong consensus.

POLL: Constant folding behavior follows runtime evaluation behavior.

SF F N A SA
5 1 0 0 0

# of Participants: 6 Outcome: Strong consensus.

POLL: Literals are always rounded to their types. (Never can a higher precision and range value be used in subsequent operations. 1.1f + x where x is a double cannot be evaluated as 1.1 + x.)

SF F N A SA
3 3 0 0 0

# of Participants: 6 Outcome: Strong consensus.

POLL: We should consider not allowing excess precision in runtime evaluation at all (except if we introduce an "attribute" that controls this, as documented in 60559). Every binary operation on floating-point is rounded once to the precision and range of its type (decltype(expr)).

SF F N A SA
2 3 0 1 0

# of Participants: 6 Outcome: Consensus in favor.

POLL: Excess precision in runtime evaluation should be a permissible optimization for implementations. The implementation choice of what intermediate type was used is reflected by FLT_EVAL_METHOD (potentially as a different trait or with the extended values as defined in C23 Annex H).

SF F N A SA
1 2 1 2 0

# of Participants: 6 Outcome: No consensus.

POLL: Comparison operators should always round their operands to the precision and range of their types in case excess precision is used. In addition to operators we expect the <cmath> comparison functions to have the same behavior (std::isless(a, b) etc...)

SF F N A SA
3 0 2 0 1

# of Participants: 6 Outcome: No consensus. SA: Not worth differing from C in this. x87 does comparison on long double types.

jfbastien commented 1 week ago

Seen in EWG on Wednesday:

Poll: CWG2752 / P3488: Floating-Point Excess Precision, FLT_EVAL_METHOD must always be 0. SF F N A SA
2 5 5 4 4

Result: not consensus

Poll: CWG2752 / P3488: Floating-Point Excess Precision, FLT_EVAL_METHOD can have any value allowed by C (this poll requires fixing some Core wording).

SF F N A SA
0 5 8 4 4

Result: not consensus