skullc-peripherals/Utility/Inc/utility_rand.hpp
Erki 60bad24319
Some checks failed
continuous-integration/drone/push Build is failing
The great renaming, part 1
2021-06-08 23:18:56 +03:00

41 lines
583 B
C++

//
// Created by erki on 29.04.21.
//
#ifndef SKULLC_UTILITY_RAND_HPP_
#define SKULLC_UTILITY_RAND_HPP_
#include <cstdint>
namespace Utility
{
inline std::uint32_t rand32(std::uint32_t& state)
{
std::uint32_t x = state;
x ^= x << 13;
x ^= x >> 17;
x ^= x << 5;
state = x;
return state;
}
inline std::uint64_t rand64(std::uint64_t& state)
{
std::uint64_t x = state;
x ^= x << 13;
x ^= x >> 7;
x ^= x << 17;
state = x;
return state;
}
void srand(const std::uint32_t& seed);
std::uint32_t rand();
}// namespace Utility
#endif//SKULLC_UTILITY_RAND_HPP_