Skip to content

Instantly share code, notes, and snippets.

@KWillets
KWillets / divless.cpp
Created August 5, 2019 22:14
Lemire's almost divisionless random int in a range, extended with some fancy 32/64 extensible arithmetic
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <random>
typedef uint32_t (*randfnc32)(void);
/*
To generate a random integer within a range, we start
with a random fractional number (in [0,1)) and multiply it