c will perform implied casts for standard data types, normally without issuing any warnings.
This can catch you out at times.
So if you try to store a float into an int then it will be rounded down to the next integer. Since floats sometimes have rounding errors this can result in the value being 1 less than expected. e.g. 5 / 2.5 should give 2.0 but due to rounding may result in 1.99999999999. When saved as an int that would then give a value of 1.
If you want to round to the nearest integer then first add 0.5.
While the casts are implied and so not technically needed it can sometimes be a good idea to still include them explicitly just to make it clearer in the code that values are going to get rounded down.
The other thing to keep in mind is how variable types are promoted by the implied casts.
e.g. consider the following two lines:
float x = 3 + 2/4.0;
float x = 3.0 + 2/4;
In the first the calculation it is: int + int / double = int + double = double
In the second it is: double + int / int = double + int = double
So both result in a double that is then converted to a float (arduino is a little non-standard here, doubles are just floats anyway).
However the resulting values will be different. The first one will give
the expected 3.5 while the second one will give 3.0 because 2/4 is an integer calculation and will have a value of 0. In order to get the correct value either the 2 or the 4 must be cast to a float or double before the division operation takes place.
For your specific questions:
Buffer[n] = (0.99 * cos(((2.0*PI)/40000)*n); is perfectly valid, all calculations will be performed as doubles and the end result cast to an int however you may get rounding issues as mentioned above. Changing the line to
Buffer[n] = (0.99 * cos(((2.0*PI)/40000)*n) + 0.5); will round to the nearest integer which is probably what you want.
For the second question,
floatVal = intVal - intVal*Buffer[intVal]; there is no need for a cast, the value will be calculated as an int and then there is an implied cast to a float. However I'm not sure what the point of using a float is here since the result is always going to be an integer, using a float will only slow things down.