is memset(ary,0,length) a portable way of inputting zero in double array
- by monkeyking
The following code uses memset to set all the bits to zero
#include <iostream>
#include <cstring>
int main(){
int length = 5;
double *array = new double[length];
memset(array,0,sizeof(double)*length);
for(int i=0;i<length;i++)
if(array[i]!=0.0)
std::cerr<< "not zero in: " <<i <<std::endl;
return 0;
}
Can I assume that this will work on all platforms?
Does the double datatype always correspond to the ieee-754 standard?
thanks