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

conflicting sentences in section "floating literals"? #513

Closed
jmarathe1 opened this issue Jun 22, 2015 · 3 comments
Closed

conflicting sentences in section "floating literals"? #513

jmarathe1 opened this issue Jun 22, 2015 · 3 comments

Comments

@jmarathe1
Copy link

The section numbers below are with reference to the working draft N4431.

  1. Towards the end of section "2.13.4 Floating literals", the standard text says:
    " If the scaled value is in the range of representable values for its type, the result is the scaled value if representable, else the larger or smaller representable value nearest the scaled value, chosen in an implementation-defined manner."
  2. But, a couple of sentences later, the standard says:
    "If the scaled value is not in the range of representable values for its type, the program is ill-formed."

The way I am parsing this, the two sentences seem to conflict:
a. According to (1), if the scaled value is not representable, the nearest value is chosen in an implementation-defined manner, so the program is valid and so (2) does not apply.
b. According to (2), if the scaled value is not representable, the program is ill-formed, but (1) should have applied here and so the program must be well-formed.

It seems to me that either of sentences (1) or (2) should be removed (likely (2) ?).

@jwakely
Copy link
Member

jwakely commented Jun 22, 2015 via email

@zygoloid
Copy link
Member

a. According to (1), if the scaled value is not representable, the nearest value is chosen in an implementation-defined manner, so the program is valid and so (2) does not apply.

You're misreading (1); it only applies in the case where the scaled value is in the range of representable values. It is intended to be parsed this way:

If the scaled value is in the range of representable values for its type, the result is:

  • the scaled value, if [the scaled value is] representable,
  • else the larger or smaller representable value nearest the scaled value, chosen in an implementation-defined manner [if the scaled value is not representable]

We could probably clarify this by adding a few words. Maybe something like:

If the scaled value is in the range of representable values for its type, the result is the scaled value if representable, else or the larger or smaller representable value nearest the scaled value, chosen in an implementation-defined manner, if the scaled value is not representable.

@jmarathe1
Copy link
Author

Right, sorry for the noise. I skipped over the first parts of the two sentences " If the scaled value is in the range.." and "If the scaled value is NOT in the range.."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants