ISO C Random Number Functions
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
randfunction can return. In the GNU library, it is2147483647, which is the largest signed integer representable in 32 bits. In other libraries, it may be as low as32767.
- Function: int rand (void)
- The
randfunction returns the next pseudo-random number in the series. The value ranges from0toRAND_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
randbefore a seed has been established withsrand, it uses the value1as 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_MAXjust asranddoes. However, all its state is stored in the seed argument. This means the RNG's state can only have as many bits as the typeunsigned inthas. 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的更多相关文章
- Case Study: Random Number Generation(翻译教材)
很荣幸,经过三天的努力.终于把自己翻译的教材做完了,现在把它贴出来,希望能指出其中的不足. Case Study: Random Number Generation Fig. 6.7 C++ 标 ...
- Random number
Original #include <stdlib.h> #include <time.h> srand(time(NULL)); rand(); The versions o ...
- 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 ...
- Linux shell get random number
the Shell Profile: When a new interactive shell is started, /etc/profile, followed by /etc/bash.bash ...
- C# random(number)
C#随机函数Random()的用法 出自:http://www.cnblogs.com/wang726zq/archive/2012/04/28/2474711.html http://blog.cs ...
- LoadRunner压力测试之Unique Number参数类型、Random Number参数类型浅析
前几天工作需要用LoadRunner进行压力测试,期间对手机号进行参数化设置. 当时选用了<Value>137{Random_quhao}{Unique_weiyi}</Value& ...
- SQL Fundamentals || Single-Row Functions || 数字函数number functions
SQL Fundamentals || Oracle SQL语言 SQL Fundamentals: Using Single-Row Functions to Customize Output使用单 ...
- 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 ...
- 文献翻译|Design of True Random Number Generator Based on Multi-stage Feedback Ring Oscillator(基于多级反馈环形振荡器的真随机数发生器设计)
基于多级反馈环形振荡器的真随机数发生器设计 摘要 真随机数生成器(trng)在加密系统中起着重要的作用.本文提出了一种在现场可编程门阵列(FPGA)上生成真随机数的新方法,该方法以 多级反馈环形振荡器 ...
随机推荐
- 什么是RAW?
RAWRAW是一个PHP网站开发系统,使用简单.快捷,核心功能是通过模版组合网站,模版可以自由开发,使开发者不再受传统开发的那种头晕限制,只需要通过填写表单即可完成网站的开发.此外,开发者还可以通过开 ...
- hdu 4704 Sum 费马小定理
题目链接 求2^n%mod的值, n<=10^100000. 费马小定理 如果a, p 互质, 那么a^(p-1) = 1(mod p) 然后可以推出来a^k % p = a^(k%(p-1) ...
- 阿里云ECS每天一件事D2:配置防火墙
在linux中配置防火墙是一件比较有风险的事情,尤其是在ECS中,一个不当心的操作,可能就会需要重置服务器. 包括阿里云的官方建议,不要配置防火墙,没有必要什么的吧啦吧啦…… (http://bbs. ...
- 基于SIM 卡卡基不同制作工艺的研究
1 国内外现行的SIM 卡卡基制作工艺 SIM 卡由卡基和芯片两部分组成.卡基上有植入芯片的台阶式芯片槽,SIM 卡的芯片通过多点焊接植入台阶式芯片槽之中与卡基组成SIM 卡,然后经过个性化数据处理, ...
- COM编程之IUnknown接口
COM组件其实是一种特殊的类,遵循一个统一的标准,使到各个软件都可以通过某种方法访问这个类的函数和方法,也就可以做到组件通用. com就是统一的标准--通过接口来调用com组件.接口是你的com组件能 ...
- BZOJ 3385: [Usaco2004 Nov]Lake Counting 数池塘
题目 3385: [Usaco2004 Nov]Lake Counting 数池塘 Time Limit: 1 Sec Memory Limit: 128 MB Description 农夫 ...
- 你应当知道的Java牛人
Java领域有非常多著名的人物,他们为Java社区编写框架.产品.工具或撰写书籍改变了Java编程的方式. 本文是<最受欢迎的8位Java牛人>的2.0版本号. PS:排名不分先后.本文的 ...
- Oracle创建表、索引、主键、字段描述
-- 创建表 create table SX04_LBALANCE ( YEAR VARCHAR2(10) not null, PROGRAMNO VARCHAR2(40) not null, FDA ...
- SpringMVC 详解
一.SpringMVC基础入门,创建一个HelloWorld程序 1.首先,导入SpringMVC需要的jar包. 2.添加Web.xml配置文件中关于SpringMVC的配置 1 2 3 4 5 6 ...
- Week 5a - Mouse input and more lists ----mouse input
<span style="font-size:14px;">import simplegui import math # global variables ball_p ...