Random numbers between -1 and 1

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
 
int main()
{
        srand(time(NULL));
        for (int i = 0; i < 100; i++) {
                float val = (2.0*((float)rand()/RAND_MAX))-1.0;
                printf ("%f\n", val);
        }
}

WordPress Pastebin plugin

About James

If this were the 80s I'd be sat in front of a C64 or Speccy, or taking VCRs apart.