<commit_before>/**
 * @file random.c
 * @author timoteus <<EMAIL>>
 */

#include "random.h"
#include "sort.h"

rock_uint_t
rock_uint_random(rock_uint_t range)
{
#ifdef ROCK_WORD_SIZE_64
    return ROCK_ERR;
#else
    if (range > RAND_MAX) {
        return ROCK_ERR;
    }
    uint32_t threshold = -range % range;
    for (;;) {
        uint32_t r = rand();
        if (r >= threshold) {
            return r % range;
        }
    }
#endif
}

double<commit_msg>Use correct error code<commit_after>/**
 * @file random.c
 * @author timoteus <<EMAIL>>
 */

#include "random.h"
#include "sort.h"

rock_uint_t
rock_uint_random(rock_uint_t range)
{
#ifdef ROCK_WORD_SIZE_64
    return ROCK_ERR;
#else
    if (range > RAND_MAX) {
        return ROCK_BAD_INPUT;
    }
    uint32_t threshold = -range % range;
    for (;;) {
        uint32_t r = rand();
        if (r >= threshold) {
            return r % range;
        }
    }
#endif
}

double
{'fraction_non_alphanumeric': 0.13020277481323372, 'fraction_numerical': 0.012806830309498399, 'mean_word_length': 2.398550724637681, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4459199', 'n_tokens_mistral': 360, 'n_tokens_neox': 353, 'n_words': 80}