I am setting an array of floats or doubles to zero, using
double* dev_ptr; // allocate memory cudaMemset(dev_ptr, 0, array_size * sizeof(double));
This works fine. But as far as I understand, this does not always work with the C version (
memset) as not all compilers implement floating point numbers to be of zero value when all bits are zero (IEEE 754 compliance, discussed e.g. here: https://stackoverflow.com/questions/8558813/if-all-bits-are-0-what-is-the-value-of-ieee-floating-point).
There is a guide on IEEE 754 compliance and CUDA and I couldn’t find anything about zero representation of floats. I just want to be sure that what I am doing will give be expected results (setting the floats to zero) on any CUDA GPU? Code portibility is important here.
I know similar questions have been asked before but none wanted to set floats to zero (only floats to non-zero or int to zero).