skullc-peripherals/Utility/Inc/utility_rand.hpp
Erki 01a091b174
All checks were successful
continuous-integration/drone/push Build is passing
Format pass
2021-04-30 18:32:07 +03:00

41 lines
588 B
C++

//
// Created by erki on 29.04.21.
//
#ifndef SKULLC_UTILITY_RAND_HPP
#define SKULLC_UTILITY_RAND_HPP
#include <cstdint>
namespace Peripherals
{
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 Peripherals
#endif//SKULLC_UTILITY_RAND_HPP