   memset for doubles?
  Is there a way to set an array of doubles using similar functionality to memset or is a loop the only way to do it (I'm using C for this project and the array needs to be initialized to a specific number that's known at compiler time and isn't 0).   
  memset goes and sets a byte at a time to the value you send in. So there really is no good way to set any meaningful value for a double - unless you know of a double that has the same byte repeating over and over. It certainly wouldn't work for any arbitrary value.On the otherhand you could write your own (templated?) custom memset operation. You would just have to take care of memory alignment stuff[edit]Oh, just saw this was a C project, so ignore the templated aspect of the custom function   ;  If you know how big your doubles are in actual bytes (8 bytes, probably), then yes, you can, you just need to know the IEEE floating point type.For a 32 bit floating point type it's (something like) this:1-sign-bit 9-bit-exponent 22-bit-mantissaThen you can find how to represent your number byte-by-byte, and memset it like that. In other words...Just use a loop.   ;  You know, when it comes down to it, memset() doesn't do anything magical: it too is just a loop? In C++, the std::fill() and std::fill_n() function templates play that role. So don't feel bad about writing your own memset-like function for doubles.   ;  I don't know but this page: http://www.daniweb.com/tutorials/tutorial1767.htmlstates that a double can be >= the size of a float. So this may work if sizeof(int) == sizeof(double) I think. (Not sure though)Pseudo code:double myvalue = 0xf00d;//change to whatever value you wantmemset(doublearray,reinterpret_cast<int>(myvalue),sizeof(double)*doublearraylen);where doublearray is your array of doubles,and doublearraylen is the number of doubles contained in that array ;)EDIT: Fixed broken source lang="cpp"-tag and a typo;  The 2nd int parameter to memset converts its argument to unsigned char AFAIK and copies char sized into is destination so the above probably won't work.As previously stated, memset is only a loop so there isn't much to be gained over writing your own initialisation loop.HTH. Paul   ;Quote:I thought IEEE 754 stated that a double is 32 bits and float is 16 bits?You thought wrong.If you want to fill doubles (or floats) with the "0" value, you can use memset(), because 0.0f is all zero bytes, as is 0.0.If you want to fill with another value, use std::fill().;  A double is 64 bits and a float is 32 bits. A long double is probably 80 bits on most platforms, although your compilers sizeof(long double) may be 12, not 10, due to padding.   