GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::random_device::entropy(3) C++ Standard Libary std::random_device::entropy(3)

std::random_device::entropy - std::random_device::entropy


double entropy() const noexcept; (since C++11)


Obtains an estimate of the random number device entropy, which is a floating-point
value between 0 and log
2(max()+1) (which is equal to std::numeric_limits<unsigned int>::digits). If the
device has n states whose individual probabilities are P
0,...,P
n-1, the device entropy S is defined as


S = -Σn-1
i=0 P
ilog(P
i)


A deterministic random number generator (e.g. a pseudo-random engine) has entropy
zero.


The value of the device entropy, or zero if not applicable.


This function is not fully implemented in some standard libraries. For example, LLVM
libc++ prior to version 12 always returns zero even though the device is
non-deterministic. In comparison, Microsoft Visual C++ implementation always returns
32, and boost.random returns 10.


The entropy of the Linux kernel device /dev/urandom may be obtained using ioctl
RNDGETENTCNT - that's what std::random_device::entropy() in GNU libstdc++ uses as of
version 8.1


Example output on one of the implementations

// Run this code


#include <iostream>
#include <random>


int main()
{
std::random_device rd;
std::cout << rd.entropy() << '\n';
}


32

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.