-
-
Save pfeilbr/8ea11ad6649c92743534bd37d7c7b572 to your computer and use it in GitHub Desktop.
This file contains 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
// gh cli test edit | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
float rand_float(float max_value) | |
{ | |
return (float)rand() / ((float)RAND_MAX / max_value); | |
} | |
float rand_float_range(float lower, float upper) | |
{ | |
return rand_float(upper - lower) + lower; | |
} | |
int main() | |
{ | |
srand(time(0)); | |
printf("rand_float: %f", rand_float_range(1.0, 2.0)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment