With the latest AlphaRNG Software API updates, it is possible to generate random and unique 32-bit signed integers within a range.

A sample source code in C++ for retrieving a sequence of 6 random int32_t numbers within [1..49] range when used with an AlphaRNG device.


#include <AlphaRngApi.h>
#include <AlphaRandomRangeSequence.h>

using namespace std;
using namespace alpharng;

/**
 * @return 0 if ran successfully
 */

#define CNT 6

int main() {

    AlphaRngApi rng { };

    if (!rng.connect(0)) {
        cerr << rng.get_last_error() << endl;
        return -1;
    }

    AlphaRandomRangeSequence api {&rng, 1, 49};
    int32_t seq_buff[CNT];

    if (!api.generate_sequence(seq_buff, CNT)) {
        cerr << api.get_last_err_msg() << endl;
        return -1;
    }

    cout << "Start of sequence:" << endl;
    for (auto i = 0; i < CNT; ++i) {
        cout << seq_buff[i] << endl;
    }
    cout << "End of sequence." << endl;

    return 0;
}