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)上生成真随机数的新方法,该方法以 多级反馈环形振荡器 ...
随机推荐
- PhoneGap笔记-01 基本使用
1. 环境配置 1.1 常用框架 jQuery Backbone.js dojo bootstrap kendo UI Sencha jQuery Mobile PhoneJS AngularJS I ...
- C#使用系统的“显示桌面”功能(Shell.Application)
原文 C#使用系统的“显示桌面”功能(Shell.Application) 在 Windows 系统的 任务栏 上的 快速启动栏 里,通常有一个图标 ,点击这个图标,就会切换到桌面.这个图标实际是一 ...
- opencv-python 学习笔记2:实现目光跟随(又叫人脸跟随)
如果机器人的脸能随着前方人脸而转动,你会不会觉得这种互动很有意思.年前的时候,学习了一下opencv,通过opencv可以简单的实现人脸跟随.再加上几个舵机控制头部转动,机器人就可以互动了.呵呵 这里 ...
- 九款让WordPress成为赚钱利器的广告插件
Blog有了很不错的流量后,看到别人博客挂的广告挣$,是否也有挂广告的冲动,但是,修改wordpress模版去让人不厌其烦,布局.样式都的重新修改一下,为了不那么麻烦,笔者整理的几款wordpress ...
- [dfs+水] hdu 4462 Scaring the Birds
题意: N*N的矩阵中有M个点能够放稻草人.且给覆盖距离R 每一个稻草人能覆曼哈顿距离R以内的点 问最少须要多少个稻草人 思路: 由于范围非常小,直接能够暴力 注意稻草人所在的位置是不须要被覆盖的 代 ...
- out/target/common/obj/PACKAGING/public_api.txt android.view.KeyEvent.KEYCODE_has changed value from
编译出错: out/target/common/obj/PACKAGING/public_api.txt:22549: error 17: Field android.view.KeyEvent.KE ...
- Linux vsftpd服务配置具体解释
[背景] 近日.一朋友dominoserver要进行升级.迁移,搭建了linux測试系统,也开启vsftpd服务,但是配置的ftp账号,程序无法正常下载附件. [问题跟踪] 通过ftpclient连接 ...
- OFbiz--HelloWorld
上篇博客<OFbiz--简单介绍>我们介绍了OFbiz是什么,以下我们就開始用OFbiz开发我们的第一个程序--HelloWorld. 过程例如以下: 首先在hot-deploy下新建文件 ...
- document.execCommand()函数可用参数解析
隐藏在暗处的方法-execCommand() 关键字: javascript document document.execCommand()方法可用来执行很多我们无法实现的操作. execComman ...
- 转换DataSet中的多个表为Excel中的多个Sheets
第一种方法: 1. 在设计页面,有一个button按钮,当用户单击按钮的时候,发生转换 <asp:Button ID="Export" runat="server& ...