Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CWG2752 Excess-precision floating-point literals #1584

Open
jensmaurer opened this issue Jun 30, 2023 · 2 comments
Open

CWG2752 Excess-precision floating-point literals #1584

jensmaurer opened this issue Jun 30, 2023 · 2 comments
Labels
C++26 Targeted at C++26 IS Ship vehicle: IS SG6 Numerics size - small paper size estimate

Comments

@jensmaurer
Copy link
Member

jensmaurer commented Jun 30, 2023

In C23, floating-point literals (called "constants" there) can be represented with excess precision, meaning a float literal is treated as a double or long double value (without affecting the type system, though).

In C++, there is no such permission.

Both C++ and C permit floating-point computations (including operands) to use excess precision. A footnote hints that a conversion will drop the excess precision (e.g. (float)(314.f/100.f) yields a value with float precision) (like C does), but there is no normative wording to make that happen.

What is the design intent for handling excess-precision floating-point computations in C++?

See CWG2752 for details.

@jensmaurer jensmaurer added the EWG Evolution label Jun 30, 2023
@mattkretz mattkretz added the SG6 Numerics label Jun 30, 2023
@jfbastien jfbastien removed the EWG Evolution label Sep 24, 2023
@jfbastien
Copy link
Collaborator

SG6 input is desired, please assign to EWG afterwards.

@inbal2l inbal2l added size - small paper size estimate C++26 Targeted at C++26 IS Ship vehicle: IS labels Oct 26, 2023
@mattkretz
Copy link
Collaborator

2023-11-07 SG6 Minutes

Chair: Matthias Kretz

Minute Taker: Philip Craig

Summary

The issue is asking

What is the design intent for handling excess-precision floating-point
computations in C++?

Nobody in SG6 felt qualified to answer this question from an "original design
intent" perspective. So the question was interpreted as stating design intent
as required by numerics users. There was no consensus for a desired behavior
and it appears that a more thorough exploration in a paper would be necessary
to aid the discussion.

Polls

  1. Compilers need to be allowed to use the x87 FPU for computation and
    comparison (without "too much" intermediate rounding)

POLL: C++ should not deviate from C in how floating-point behaves (excess
precision, fp contraction, literals)

SF F N A SA
0 3 1 1 1

# of Participants: 7
Outcome: No consensus for change
Comments: We could really use a paper to make a more informed decision. The
paper would need to explore the consequences of all the different options.

Polls considered, but not taken without a better understanding of the
consequences:

POLL: The C++ standard should allow floating-point contraction into FMAs by
default.

(We disagreed on whether the current wording in [expr.pre] allows fp
contraction. Therefore, there was no clear "status-quo" position.)

POLL: There needs to be a standard-conforming way to control floating-point
contraction.

@mattkretz mattkretz added the paper needed An issue needs a paper to describe its solution label Mar 20, 2024
@mattkretz mattkretz removed the paper needed An issue needs a paper to describe its solution label Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++26 Targeted at C++26 IS Ship vehicle: IS SG6 Numerics size - small paper size estimate
Projects
Status: 2024-11 Wroclaw
Development

No branches or pull requests

4 participants