Created
November 9, 2019 13:37
-
-
Save hokamoto/3853d9ebd59957d17d5b929c6787f2b0 to your computer and use it in GitHub Desktop.
Generate a random number by RDRAND operation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <immintrin.h> | |
#include <stdio.h> | |
unsigned int rnd() { | |
unsigned int r = 0; | |
_rdrand32_step(&r); | |
return r; | |
} | |
int main() { | |
for(int i=0;i<100;i++) { | |
printf("%u\n", rnd()); | |
} | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment