Skip to content

Instantly share code, notes, and snippets.

@antoinefortin
Created July 14, 2022 06:56
Show Gist options
  • Save antoinefortin/39ac399b7a5bde3ae26da10b19ef71e0 to your computer and use it in GitHub Desktop.
Save antoinefortin/39ac399b7a5bde3ae26da10b19ef71e0 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <intrin.h>
#include <cmath>
uint64_t rdtsc() {
return __rdtsc();
}
float random0t1(uint64_t cpuClock)
{
float parcels = abs(sin(cpuClock) * cos(sin(cpuClock / 2)));
return parcels;
}
int randomN(uint64_t cpuClock, int s)
{
float parcels = abs(sin(cpuClock) * cos(sin(cpuClock / 2)));
int res = parcels * s;
return res;
}
int main()
{
// debug press enter
while (true)
{
std::cin.ignore();
uint64_t currClock = rdtsc();
float random = random0t1(currClock);
int nr = randomN(currClock, 55);
std::cout << currClock << std::endl;
std::cout << nr << std::endl;
std::cout << random << std::endl;
}
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment