Skip to content

Instantly share code, notes, and snippets.

@pfeilbr
Last active September 21, 2020 15:25
Show Gist options
  • Save pfeilbr/8ea11ad6649c92743534bd37d7c7b572 to your computer and use it in GitHub Desktop.
Save pfeilbr/8ea11ad6649c92743534bd37d7c7b572 to your computer and use it in GitHub Desktop.
// 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