
linux@celticblues.com wrote:
Does boost have a float-to-integer conversion?
There is Boost.NumericConversion http://www.boost.org/libs/numeric/conversion/doc/index.html which provides: boost::numeric_cast<int>(your_float) That conversion funtion will round even and throw an exception if the float is out of range.
I need a routine to convert a 32 bit single precision float (1S 8E 23M) to integer, with the end goal being that I can take the integer break it down into bytes... i.e.bits 0-7, 8-15,16-23,24-31.
Then I suspect you don't really want to "convert" the float to int but to get at the value-representation of the float. If that's the case, you can do this: char* float_value_rep = static_cast<char*>(static_cast<void*>(&your_float)); HTH -- Fernando Cacciola SciSoft http://fcacciola.50webs.com http://groups.google.com/group/cppba