This section describes the random number functions that are part of the ISO C standard.

To use these facilities, you should include the header file `stdlib.h' in your program.

Macro: int RAND_MAX
The value of this macro is an integer constant representing the largest value the rand function can return. In the GNU library, it is 2147483647, which is the largest signed integer representable in 32 bits. In other libraries, it may be as low as 32767.
Function: int rand (void)
The rand function returns the next pseudo-random number in the series. The value ranges from 0 to RAND_MAX.
Function: void srand (unsigned int seed)
This function establishes seed as the seed for a new series of pseudo-random numbers. If you call rand before a seed has been established with srand, it uses the value 1 as a default seed.

To produce a different pseudo-random series each time your program is run, do srand (time (0)).

POSIX.1 extended the C standard functions to support reproducible random numbers in multi-threaded programs. However, the extension is badly designed and unsuitable for serious work.

Function: int rand_r (unsigned int *seed)
This function returns a random number in the range 0 to RAND_MAX just as rand does. However, all its state is stored in the seed argument. This means the RNG's state can only have as many bits as the type unsigned int has. This is far too few to provide a good RNG.

If your program requires a reentrant RNG, we recommend you use the reentrant GNU extensions to the SVID random number generator. The POSIX.1 interface should only be used when the GNU extensions are not available.

ISO C Random Number Functions的更多相关文章

  1. Case Study: Random Number Generation(翻译教材)

    很荣幸,经过三天的努力.终于把自己翻译的教材做完了,现在把它贴出来,希望能指出其中的不足.   Case Study: Random Number Generation Fig. 6.7  C++ 标 ...

  2. Random number

    Original #include <stdlib.h> #include <time.h> srand(time(NULL)); rand(); The versions o ...

  3. How to generate a random number in R

    Generate a random number between 5.0 and 7.5x1 <- runif(1, 5.0, 7.5) # 参数1表示产生一个随机数x2 <- runif ...

  4. Linux shell get random number

    the Shell Profile: When a new interactive shell is started, /etc/profile, followed by /etc/bash.bash ...

  5. C# random(number)

    C#随机函数Random()的用法 出自:http://www.cnblogs.com/wang726zq/archive/2012/04/28/2474711.html http://blog.cs ...

  6. LoadRunner压力测试之Unique Number参数类型、Random Number参数类型浅析

    前几天工作需要用LoadRunner进行压力测试,期间对手机号进行参数化设置. 当时选用了<Value>137{Random_quhao}{Unique_weiyi}</Value& ...

  7. SQL Fundamentals || Single-Row Functions || 数字函数number functions

    SQL Fundamentals || Oracle SQL语言 SQL Fundamentals: Using Single-Row Functions to Customize Output使用单 ...

  8. sqlserver datatime value plus random number

    If we want to make some identiity value in sqlserver , we can use identity data type in a table.Howe ...

  9. 文献翻译|Design of True Random Number Generator Based on Multi-stage Feedback Ring Oscillator(基于多级反馈环形振荡器的真随机数发生器设计)

    基于多级反馈环形振荡器的真随机数发生器设计 摘要 真随机数生成器(trng)在加密系统中起着重要的作用.本文提出了一种在现场可编程门阵列(FPGA)上生成真随机数的新方法,该方法以 多级反馈环形振荡器 ...

随机推荐

  1. google浏览器的安装

    很简单,命令行下安装命令:apt-get install google-chrome-stable(如安装不成功,输入apt-get -f install进行修复依赖,之后在菜单里就可以看到图标了) ...

  2. [转]IOS Segment页面之间view的切换

    有三个view,分别为view1.view2.view3,通过UISegmentedControl进行三个view的切换. @interface UIViewDemoViewController :  ...

  3. ThreadSafeClientConnManager用来支持多线程的使用http client

    import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.clien ...

  4. kinect for windows - SkeletonBasics-D2D详解之二

    首先看骨骼追踪例子代码的结构:

  5. powerdesigner数据建模

    目标: 本文主要介绍PowerDesigner中概念数据模型 CDM的基本概念.一.概念数据模型概述数据模型是现实世界中数据特征的抽象.数据模型应该满足三个方面的要求:1)能够比较真实地模拟现实世界2 ...

  6. EGL接口 简单介绍

    from http://lyodev.appspot.com 第二章 EGL 接口 EGL 是 OpenGL ES 和底层 Native 平台视窗系统之间的接口.本章主要讲述 OpenGL ES 的 ...

  7. liquibase之快速入门

    第一步: 创建一个Changelog File: 这个database  Changelog file列举了数据库中所有的改变情况,该文件是以xml为基础的,下面是一个空的xml文件: <?xm ...

  8. MYSQL大小写(由于数据由windows迁移到Linux导致)

    今日从sqlserver上迁移了一个数据库到Linux的MySQL中,迁移成功了,但是应用却跑不通,查看日志发现,提示找不到表,我注意到,表名都是存在大小写的,而MySQL中的表名都是小写的.这提醒了 ...

  9. 2.3.9 用NPOI操作EXCEL--通过NPOI获得公式的返回值

    前面我们学习了通过NPOI向Excel中设置公式,那么有些读者可能会问:“NPOI能不能获取公式的返回值呢?”,答案是可以!一.获取模板文件中公式的返回值如在D盘中有一个名为text.xls的Exce ...

  10. springdata+redis配置详解

    springdata设计初衷是位简化数据类型和数据的持久化存储,它并不局限是关系型数据库还是nosql数据库,都提供了简化的数据库连接,让数据获取变得更加的简单.所有这些的实现有统一的api提供. 本 ...