memset() works on raw memory, so you filled the bytes of 'a' with the value 50, which in turn makes every double value in a be 0x3232323232323232, which who knows what that is.
If you want to fill 'a' with doubles having the value 50.0, you should use std::fill().
1 2 3
const size_t size = 1000;
double a[size];
std::fill(a, a + size, 50.0); //declared in <algorithm>
Here's a couple examples of memset() being used on integer values:
dig a little more...
the only generally useful thing you can really memset doubles to is zero, as all zero bytes = 0 in IEEE format etc. Its more or less the same for ints -- zero is useful and most other things are not usually. In both cases its probably a little slower because loading 8 bytes one by one into a double (or 64 bit int) is not as efficient as moving all 8 at one operation using the cpu's double copy to double hardware. Its been quite a while since I have felt any need to use it.
JSYK, not all C/C++ systems use IEEE formatted values for floats and doubles. (But I don’t recall — or believe — that any of them will fail to be 0.0 for all bytes = 0.)
In any case, the point is that you should prefer to initialize using the typed value over initializing with a raw memory wipe.