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

[rand.eng.mers] should use math font for (1u<<w)-1u #4292

Open
jwakely opened this issue Oct 7, 2020 · 6 comments · May be fixed by #4295
Open

[rand.eng.mers] should use math font for (1u<<w)-1u #4292

jwakely opened this issue Oct 7, 2020 · 6 comments · May be fixed by #4295
Assignees

Comments

@jwakely
Copy link
Member

jwakely commented Oct 7, 2020

In [rand.eng.mers] p4 the expression (1u<<w) - 1u is used repeatedly. If w==numeric_limits<unsigned>::digits that is ill-formed.

In the synopsis above we use { return 2w - 1; } despite that being actual C++ code, so why can't we do the same in the prose that follows it?

i.e. replace the code font expressions like a <= (1u<<w) - 1u with a ≤ 2w - 1 to be clear that the rules of C++ unsigned integer arithmetic do not apply.

@tkoeppe
Copy link
Contributor

tkoeppe commented Oct 7, 2020

Should all the relations in that paragraph be maths, not code?

@jwakely
Copy link
Member Author

jwakely commented Oct 7, 2020

That would probably be an improvement, but the only one that causes me physical pain is the one that won't compile.

Every engine and engine adaptor in [rand.eng] and [rand.adapt] has similar relations as code, but I think [rand.eng.mers] is the only one that's a real problem.

@tkoeppe
Copy link
Contributor

tkoeppe commented Oct 7, 2020

Hm, maybe we need more thorough cleanup. I don't like silently conflating different symbols, and w and w are different things. We should have proper introductions that say "here's a quantity w that does XYZ, and the template parameter w has the value w etc.

Once everything is properly defined and bound, we can consider mixing relational C++ expressions and mathematical inequalities, though I'd still prefer if we could just use one (i.e. just mathematical inequalities).

@jwakely
Copy link
Member Author

jwakely commented Oct 8, 2020

[rand.eng.lcond] p3 would be simpler stated as maths:

If the template parameter m is not 0, the following relations shall hold: a < m and c < m.

We don't need to special case m==0 in both p2 and p3, we can just rely on p2 to rewrite p3 as:

The following relations shall hold: a < m and c < m.

(Yes, we should introduce a and c instead of a and c, but note that p5 and p6 already use a and c without introduction anyway!)

@jwakely
Copy link
Member Author

jwakely commented Oct 8, 2020

I think we should put blanket wording in [rand.eng] saying that a placeholder p has the value of the template argument that is substituted for the template parameter of the same name, p. That way we don't need each engine or adaptor to say "the multiplier a has the value of the template argument that is substituted for the template parameter a" for every parameter.

@tkoeppe
Copy link
Contributor

tkoeppe commented Oct 8, 2020

Yes, blanket wording would help a lot.

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

Successfully merging a pull request may close this issue.

2 participants