English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2006-08-28 21:41:06 · 4 answers · asked by anitha s 1 in Computers & Internet Computer Networking

I need the implementation of the generation of floating point random numbers using Linux C

2006-08-29 19:04:56 · update #1

4 answers

Your answer is not specific.
Assuming your questions in terms of software -> databases
you can use a database object called "sequence" to do so

2006-08-28 21:52:35 · answer #1 · answered by Anonymous · 0 0

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

ATTN: In the following text where ever I used the term r a n d , it automatically converted to ****. I dont know why.

Macro: int R A N D_MAX

The value of this macro is an integer constant expression that represents the maximum possible value returned by the rand function. In the GNU library, it is 037777777, which is the largest signed integer representable in 32 bits. In other libraries, it may be as low as 32767.

Function: int rand ()

The rand function returns the next pseudo-random number in the series. The value is in the range 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 truly random numbers (not just pseudo-random), do srand (time (0)).


BSD Random Number Functions
This section describes a set of random number generation functions that are derived from BSD. There is no advantage to using these functions with the GNU C library; we support them for BSD compatibility only.

The prototypes for these functions are in `stdlib.h'.

Function: long int random ()

This function returns the next pseudo-random number in the sequence. The range of values returned is from 0 to RAND_MAX.

Function: void srandom (unsigned int seed)

The srandom function sets the seed for the current random number state based on the integer seed. If you supply a seed value of 1, this will cause random to reproduce the default set of random numbers.

To produce truly random numbers (not just pseudo-random), do srandom (time (0)).

Function: void * initstate (unsigned int seed, void *state, size_t size)

The initstate function is used to initialize the random number generator state. The argument state is an array of size bytes, used to hold the state information. The size must be at least 8 bytes, and optimal sizes are 8, 16, 32, 64, 128, and 256. The bigger the state array, the better.

The return value is the previous value of the state information array. You can use this value later as an argument to setstate to restore that state.

Function: void * setstate (void *state)

The setstate function restores the random number state information state. The argument must have been the result of a previous call to initstate or setstate.

The return value is the previous value of the state information array. You can use thise value later as an argument to setstate to restore that state.

2006-09-04 03:49:15 · answer #2 · answered by inline_function 3 · 0 0

In C, the responsibility of seeding random number formula falls to the one who writes applications and the popular form is calling up system time to seed the formula; that garantees uniqueness.

The responsibility of that is now taken care of internally in Java and all other modern languages.

2006-08-29 04:55:25 · answer #3 · answered by Andy T 7 · 0 0

there are random library functionc available and also to get unique ones.....

for ex. rand(i) in c.

2006-08-29 05:05:17 · answer #4 · answered by andagadu 1 · 0 0

fedest.com, questions and answers