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)上生成真随机数的新方法,该方法以 多级反馈环形振荡器 ...
随机推荐
- yoeman构建Asp.net core项目并且实现分层
在Mac上开发使用yoeman构建Asp.net core项目并且实现分层引用 1.Yoeman? yoeman是一个自动化脚手架工具.它提供很多generator,generator相当于Visua ...
- 射频识别技术漫谈(16)——Mifare UltraLight
Mifare UltraLight又称为MF0,从UltraLight(超轻的)这个名字就可以看出来,它是一个低成本.小容量的卡片.低成本,是指它是目前市场中价格最低的遵守ISO14443A协议的芯片 ...
- oracle命令大全
内容包括三大项: 1.oracle基本操作语句 2.SQLServer基本操作语句 3.各种数据库连接方法 ******************************************* ...
- 基于Visual C++2013拆解世界五百强面试题--题15-递归相加
有一分数序列: 1/2 , 1/4 , 1/6 , 1/8 ......,用递归的方法,求此数列20项之和. 可以看出规律:每一项位1/n*2 这个很容易些递归,但是要注意一点,使用浮点数相除保存: ...
- 不同服务器之间使用svn钩子post-commit同步代码遇到的证书认证问题.md
遇到的问题,以下其他问题都是因解决这个问题引申出来的问题 VisualSVN hooks自动同步更新到web服务器 错误信息如下: Error validating server certificat ...
- BZOJ 3211 花神游历各国 (树状数组+并查集)
题解:首先,单点修改求区间和可以用树状数组实现,因为开平方很耗时间,所以在这个方面可以优化,我们知道,开平方开几次之后数字就会等于1 ,所以,用数组记录下一个应该开的数,每次直接跳到下一个不是1的数字 ...
- JAVA中List、Map、Set的区别与选用
类层次关系如下: Collection ├List│├LinkedList│├ArrayList│└Vector│ └Stack└SetMap├Hashtable├HashMap └WeakHashM ...
- Warning: Unable to send packet: Error with PF_PACKET send() [11]: Message too long (errno = 90)
今天在使用tcpreplay重放流量时,发现有的数据包没有发送成功: Warning: Unable to send packet: Error with PF_PACKET send() [215] ...
- jvm的内存区域简介
1.内存区域划分 jvm在执行java程序过程中会将管理的内存划分成若干不同的数据区域,他们分别是程序计数器,堆,方法区,虚拟机栈,本地方法栈. 1.1指令计数器 指令计数器是线程私有的,每个线程都有 ...
- 移除GridView中的重复项
1. The HTML Markup <div> <asp:GridView ID="GridView1" runat="server" Au ...