Difference between data types (int8 and float)

how? the number is 2000, you tell malloc to make 2000 elements


float *arr=(float*)malloc(size*sizeof(float));

2000*4^^^

you need to either change the size or the type for example


float *arr=(float*)malloc(size*sizeof(int8_t));

will return pointer to 500 elements of type float. still no idea what you are doing but I’m already annoyed enough to not care