Current location - Trademark Inquiry Complete Network - Futures platform - C++rand function source code
C++rand function source code
The rand source code of glibc is as follows:

Internationalorganizations (same as international organizations)

__random_r? (buf,? Results)

struct? random_data? * buf

int32_t? * Results;

{

int32_t? * state;

What if? (buf? ==? NULL? ||? The result? ==? Empty)

goto? Failure;

Status? =? buf-& gt; State;

What if? (buf-& gt; rand_type? ==? TYPE_0)

{

int32_t? Val. =? Status [0];

Val. =? ((Status [0]? *? 1 1035 15245)? +? 12345)? & amp? 0x7fffffff

Status [0]? =? val

* The result? =? val

}

other

{

int32_t? *fptr? =? buf-& gt; fptr

int32_t? *rptr? =? buf-& gt; rptr

int32_t? *end_ptr? =? buf-& gt; end _ ptr

int32_t? val

Val. =? *fptr? +=? * rptr

/*? Giggle? At least? Random? A little. */

* The result? =? (Val? & gt& gt? 1)? & amp? 0x7fffffff

++ fptr;

What if? (fptr? & gt=? end_ptr)

{

fptr? =? State;

++ rptr;

}

other

{

++ rptr;

What if? (rptr? & gt=? end_ptr)

rptr? =? State;

}

buf-& gt; fptr? =? fptr

buf-& gt; rptr? =? rptr

}

Return? 0;

Failure:

__set_errno? (ein val);

Return? - 1;

} Reference:? /lattera/glibc/blob/master/stdlib/random _ r . c