<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qrandom.cpp --> <title>QRandomGenerator64 Class | Qt Core 5.12.6</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td >Qt 5.12</td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QRandomGenerator64</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right"><a href="qtcore-index.html">Qt 5.12.6 Reference Documentation</a></td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#public-types">Public Types</a></li> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">QRandomGenerator64 Class</h1> <!-- $$$QRandomGenerator64-brief --> <p>The <a href="qrandomgenerator64.html">QRandomGenerator64</a> class allows one to obtain 64-bit random values from a high-quality, seed-less Random Number Generator. <a href="#details">More...</a></p> <!-- @@@QRandomGenerator64 --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QRandomGenerator64></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += core</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign"> Qt 5.10</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qrandomgenerator.html">QRandomGenerator</a></td></tr></table></div><ul> <li><a href="qrandomgenerator64-members.html">List of all members, including inherited members</a></li> </ul> <a name="public-types"></a> <h2 id="public-types">Public Types</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qrandomgenerator64.html#result_type-typedef">result_type</a></b></td></tr> </table></div> <a name="public-functions"></a> <h2 id="public-functions">Public Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> quint64 </td><td class="memItemRight bottomAlign"><b><a href="qrandomgenerator64.html#generate">generate</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QRandomGenerator64::result_type </td><td class="memItemRight bottomAlign"><b><a href="qrandomgenerator64.html#operator-28-29">operator()</a></b>()</td></tr> </table></div> <ul> <li class="fn">16 public functions inherited from <a href="qrandomgenerator.html#public-functions">QRandomGenerator</a></li> </ul> <h3>Additional Inherited Members</h3> <ul> <li class="fn">5 static public members inherited from <a href="qrandomgenerator.html#static-public-members">QRandomGenerator</a></li> </ul> <a name="details"></a> <!-- $$$QRandomGenerator64-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qrandomgenerator64.html">QRandomGenerator64</a> class allows one to obtain 64-bit random values from a high-quality, seed-less Random Number Generator.</p> <p><a href="qrandomgenerator64.html">QRandomGenerator64</a> is a simple adaptor class around <a href="qrandomgenerator.html">QRandomGenerator</a>, making the <a href="qrandomgenerator.html#generate64">QRandomGenerator::generate64</a>() function the default for <a href="qrandomgenerator64.html#operator-28-29">operator</a>()(), instead of the function that returns 32-bit quantities. This class is intended to be used in conjunction with Standard Library algorithms that need 64-bit quantities instead of 32-bit ones.</p> <p>In all other aspects, the class is the same. Please refer to <a href="qrandomgenerator.html">QRandomGenerator</a>'s documentation for more information.</p> </div> <p><b>See also </b><a href="qrandomgenerator.html">QRandomGenerator</a>.</p> <!-- @@@QRandomGenerator64 --> <div class="types"> <h2>Member Type Documentation</h2> <!-- $$$result_type --> <h3 class="fn" id="result_type-typedef"><a name="result_type-typedef"></a>typedef QRandomGenerator64::<span class="name">result_type</span></h3> <p>A typedef to the type that <a href="qrandomgenerator64.html#operator-28-29">operator</a>() returns. That is, quint64.</p> <p><b>See also </b><a href="qrandomgenerator64.html#operator-28-29">operator</a>().</p> <!-- @@@result_type --> </div> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$generate[overload1]$$$generate --> <h3 class="fn" id="generate"><a name="generate"></a><span class="type"><a href="qtglobal.html#quint64-typedef">quint64</a></span> QRandomGenerator64::<span class="name">generate</span>()</h3> <p>Generates one 64-bit random value and returns it.</p> <p>Note about casting to a signed integer: all bits returned by this function are random, so there's a 50% chance that the most significant bit will be set. If you wish to cast the returned value to qint64 and keep it positive, you should mask the sign bit off:</p> <pre class="cpp"> <span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> value <span class="operator">=</span> QRandomGenerator64<span class="operator">::</span>generate() <span class="operator">&</span> std<span class="operator">::</span>numeric_limits<span class="operator"><</span><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span><span class="operator">></span><span class="operator">::</span>max(); </pre> <p><b>See also </b><a href="qrandomgenerator.html">QRandomGenerator</a> and <a href="qrandomgenerator.html#generate64">QRandomGenerator::generate64</a>().</p> <!-- @@@generate --> <!-- $$$operator()[overload1]$$$operator() --> <h3 class="fn" id="operator-28-29"><a name="operator-28-29"></a><span class="type"><a href="qrandomgenerator64.html#result_type-typedef">QRandomGenerator64::result_type</a></span> QRandomGenerator64::<span class="name">operator()</span>()</h3> <p>Generates a 64-bit random quantity and returns it.</p> <p><b>See also </b><a href="qrandomgenerator.html#generate">QRandomGenerator::generate</a>() and <a href="qrandomgenerator.html#generate64">QRandomGenerator::generate64</a>().</p> <!-- @@@operator() --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2019 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br/> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br/> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. </p> </div> </body> </html>