<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 4153: Fix extra "-1" for philox_engine::max()</title>
<meta property="og:title" content="Issue 4153: Fix extra &quot;-1&quot; for philox_engine::max()">
<meta property="og:description" content="C++ library issue. Status: WP">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue4153.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#WP">WP</a> status.</em></p>
<h3 id="4153"><a href="lwg-defects.html#4153">4153</a>. Fix extra "-1" for <code>philox_engine::max()</code></h3>
<p><b>Section:</b> 29.5.4.5 <a href="https://wg21.link/rand.eng.philox">[rand.eng.philox]</a> <b>Status:</b> <a href="lwg-active.html#WP">WP</a>
 <b>Submitter:</b> Ruslan Arutyunyan <b>Opened:</b> 2024-09-18 <b>Last modified:</b> 2024-11-28</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all other</b> <a href="lwg-index.html#rand.eng.philox">issues</a> in [rand.eng.philox].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#WP">WP</a> status.</p>
<p><b>Discussion:</b></p>
<p>
There is a typo in <code class='backtick'>philox_engine</code> wording that makes "-1" two times
instead of one for <code class='backtick'>max()</code> method.
The reason for that typo is that the wording was originally inspired by
<code class='backtick'>mersenne_twister_engine</code> but after getting feedback that what is written in
the <code class='backtick'>philox_engine</code> synopsis is not C++ code, the authors introduced the
<i>m</i> variable (as in <code class='backtick'>subtract_with_carry_engine</code>) but forgot to remove
"-1" in the <i>m</i> definition.
</p>
<p>
Note: after the proposed resolution below is applied the <i>m</i> variable
could be reused in other places: basically in all places where the <code class='backtick'>mod  2^w</code>
pattern appears (like <code class='backtick'>subtract_with_carry_engine</code> does).
The authors don’t think it’s worth changing the rest of the wording to reuse
the <i>m</i> variable.
If somebody thinks otherwise, please provide such feedback.
</p>

<p><i>[2024-10-02; Reflector poll]</i></p>

<p>
Set status to Tentatively Ready after six votes in favour during reflector poll.
</p>

<p><i>[Wrocław 2024-11-23; Status changed: Voting &rarr; WP.]</i></p>



<p id="res-4153"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="https://wg21.link/N4988" title=" Working Draft, Programming Languages — C++">N4988</a>.
</p>

<ol>
<li><p>Modify 29.5.4.5 <a href="https://wg21.link/rand.eng.philox">[rand.eng.philox]</a> as indicated:</p>
<blockquote>
-1-
A <code class='backtick'>philox_engine</code> random number engine produces unsigned integer random numbers
in the <del>closed</del> interval [0, <i>m</i><del>]</del><ins>)</ins>,
where <i>m</i> = 2<sup><i>w</i></sup><del> − 1</del>
and the template parameter <i>w</i> defines the range of the produced numbers.
</blockquote>
</li>
</ol>






</body>
</html>
