## Random Number Generation

Random Number Generation — Random number generation

## Synopsis

    #define             oil_rand_s32                        ()
    #define             oil_rand_s16                        ()
    #define             oil_rand_s8                         ()
    #define             oil_rand_u32                        ()
    #define             oil_rand_u16                        ()
    #define             oil_rand_u8                         ()
    #define             oil_rand_s64                        ()
    #define             oil_rand_u64                        ()
    #define             oil_rand_f32                        ()
    #define             oil_rand_f64                        ()
    void                oil_random_alpha                    (oil_type_u8 *dest,
                                                             int n);
    void                oil_random_argb                     (oil_type_u32 *dest,
                                                             int n);
    void                oil_random_f32                      (oil_type_f32 *dest,
                                                             int n);
    void                oil_random_f64                      (oil_type_f64 *dest,
                                                             int n);
    void                oil_random_s16                      (oil_type_s16 *dest,
                                                             int n);
    void                oil_random_s32                      (oil_type_s32 *dest,
                                                             int n);
    void                oil_random_s64                      (oil_type_s64 *dest,
                                                             int n);
    void                oil_random_s8                       (oil_type_s8 *dest,
                                                             int n);
    void                oil_random_u16                      (oil_type_u16 *dest,
                                                             int n);
    void                oil_random_u32                      (oil_type_u32 *dest,
                                                             int n);
    void                oil_random_u64                      (oil_type_u64 *dest,
                                                             int n);
    void                oil_random_u8                       (oil_type_u8 *dest,
                                                             int n);

## Description

## Details

### oil_rand_s32()

    #define oil_rand_s32() ((rand()&0xffff)<<16 | (rand()&0xffff))

Evaluates to a random integer in the range [-(1<<31), (1<<31)-1].

### oil_rand_s16()

    #define oil_rand_s16() ((int16_t)(rand()&0xffff))

Evaluates to a random integer in the range [-(1<<15), (1<<15)-1].

### oil_rand_s8()

    #define oil_rand_s8() ((int8_t)(rand()&0xffff))

Evaluates to a random integer in the range [-(1<<7), (1<<7)-1].

### oil_rand_u32()

    #define oil_rand_u32() ((uint32_t)((rand()&0xffff)<<16 | (rand()&0xffff)))

Evaluates to a random integer in the range [0, (1<<32)-1].

### oil_rand_u16()

    #define oil_rand_u16() ((uint16_t)(rand()&0xffff))

Evaluates to a random integer in the range [0, (1<<16)-1].

### oil_rand_u8()

    #define oil_rand_u8() ((uint8_t)(rand()&0xffff))

Evaluates to a random integer in the range [0, (1<<8)-1].

### oil_rand_s64()

    #define oil_rand_s64() ((int64_t)(oil_rand_s32())<<32 | oil_rand_s32())

Evaluates to a random integer in the range [-(1<<63), (1<<63)-1].

### oil_rand_u64()

    #define oil_rand_u64() ((uint64_t)(oil_rand_u32())<<32 | oil_rand_u32())

Evaluates to a random integer in the range [0, (1<<64)-1].

### oil_rand_f32()

    #define oil_rand_f32() (rand()/(RAND_MAX+1.0))

Evaluates to a random single-precision floating point number in the range [0, 1.0).

### oil_rand_f64()

    #define oil_rand_f64() (((rand()/(RAND_MAX+1.0))+rand())/(RAND_MAX+1.0))

Evaluates to a random double-precision floating point number in the range [0, 1.0).

### oil_random_alpha ()

    void                oil_random_alpha                    (oil_type_u8 *dest,
                                                             int n);

Writes random values in the range [0, 255] to the destination array suitable for alpha values. This is similar to `oil_random_u8()`, except the values 0 and 255 are strongly favored.

`dest` : |
`n` : |

### oil_random_argb ()

    void                oil_random_argb                     (oil_type_u32 *dest,
                                                             int n);

Creates valid random RGBA values and places them in the destination array.

`dest` : | destination array.
`n` : | number of values to write.

### oil_random_f32 ()

    void                oil_random_f32                      (oil_type_f32 *dest,
                                                             int n);

Writes random single-precision floating point values in the range [0, 1.0) to the destination array.

`dest` : |
`n` : |

### oil_random_f64 ()

    void                oil_random_f64                      (oil_type_f64 *dest,
                                                             int n);

Writes random double-precision floating point values in the range [0, 1.0) to the destination array.

`dest` : |
`n` : |

### oil_random_s16 ()

    void                oil_random_s16                      (oil_type_s16 *dest,
                                                             int n);

Writes random values in the range [-(1<<15), (1<<15)-1] to the destination array.

`dest` : |
`n` : |

### oil_random_s32 ()

    void                oil_random_s32                      (oil_type_s32 *dest,
                                                             int n);

Writes random values in the range [-(1<<31), (1<<31)-1] to the destination array.

`dest` : |
`n` : |

### oil_random_s64 ()

    void                oil_random_s64                      (oil_type_s64 *dest,
                                                             int n);

Writes random values in the range [-(1<<63), (1<<63)-1] to the destination array.

`dest` : |
`n` : |

### oil_random_s8 ()

    void                oil_random_s8                       (oil_type_s8 *dest,
                                                             int n);

Writes random values in the range [-(1<<7), (1<<7)-1] to the destination array.

`dest` : |
`n` : |

### oil_random_u16 ()

    void                oil_random_u16                      (oil_type_u16 *dest,
                                                             int n);

Writes random values in the range [0, (1<<16)-1] to the destination array.

`dest` : |
`n` : |

### oil_random_u32 ()

    void                oil_random_u32                      (oil_type_u32 *dest,
                                                             int n);

Writes random values in the range [0, (1<<32)-1] to the destination array.

`dest` : |
`n` : |

### oil_random_u64 ()

    void                oil_random_u64                      (oil_type_u64 *dest,
                                                             int n);

Writes random values in the range [0, (1<<64)-1] to the destination array.

`dest` : |
`n` : |

### oil_random_u8 ()

    void                oil_random_u8                       (oil_type_u8 *dest,
                                                             int n);

Writes random values in the range [0, (1<<8)-1] to the destination array.

`dest` : |
`n` : |