<commit_before>#include "utils.h"
#include <n/defines.h>

namespace n {
namespace core {

const void *null = 0;

uint random(uint max, uint min) {
	static bool seed = false;
	if(!seed) {
		#ifdef N_DEBUG
		srand(0);
		#else
		time_t now = time(0);
		srand(hash(&now, sizeof(now)));
		#endif
		seed = true;
	}
	return (uint)rand() % (max - min) + min;
}

float random() {
	return (float)random(RAND_MAX) * 1.0f / (RAND_MAX + 1.0f);
}

float toDeg(float a) {
	return a * 180 / N_PI;
}

float toRad(float a) {
	return a / 180 * N_PI;
}<commit_msg>Fixed random being limited by RAND_MAX<commit_after>#include "utils.h"
#include <n/defines.h>

namespace n {
namespace core {

const void *null = 0;

uint randHelper() {
	uint bits = log2ui(RAND_MAX);
	uint num;
	for(uint i = 0; i < sizeof(uint) * 8; i += bits) {
		num = (num << bits) | rand();
	}
	return num;
}

uint random(uint max, uint min) {
	static bool seed = false;
	if(!seed) {
		#ifdef N_DEBUG
		srand(0);
		#else
		time_t now = time(0);
		srand(hash(&now, sizeof(now)));
		#endif
		seed = true;
	}
	return (uint)randHelper() % (max - min) + min;
}

float random() {
	return (float)random(RAND_MAX) * 1.0f / (RAND_MAX + 1.0f);
}

float toDeg(float a) {
	return a * 180 / N_PI;
}

float toRad(float a) {
	return a / 180 * N_PI;
}
{'fraction_non_alphanumeric': 0.16510903426791276, 'fraction_numerical': 0.022585669781931463, 'mean_word_length': 3.4463667820069204, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 5, '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': '3575312', 'n_tokens_mistral': 576, 'n_tokens_neox': 537, 'n_words': 146}