Is this assignment valid or needs casting?
First part:

uint16_t Buffer[40000];

for (int n=0; n&lt;40000 ; n++){
  Buffer[n] = (0.99 * cos(((2.0*PI)/40000)*n);
}


Buffer[n] will be filled with an uint16_t and implicit casting to an uint16_t will be used. I suggest you do such implicit castings explicitly (so add (uint16_t) ... if you want).

However, if you do not want this, either define the Buffer as float, or at least add + 0.5 to give better roundings (if that is improving, depends on your situation, but mathematically it is better).

thus:

static const uint8_t BUFFER_SIZE = 40000;
uint16_t Buffer[BUFFER_SIZE];

for (int n=0; n&lt;BUFFER_SIZE; n++)
{
  Buffer[n] = (int) (0.99 * cos(((2.0*PI)/BUFFER_SIZE)*n));
}


The next one:

int intVal;
float floatVal;

floatVal = intVal - intVal*Buffer[intVal];


This is also 'compiler-correct', and an int value can be more easier converted to a float. You will not lose digits. However, to make it clear an explicit cast with (int) ... is better.

Thus:

int intVal;
float floatVal = (float) (intVal - intVal*Buffer[intVal]);