Boost logo

Boost Users :

From: Fernando Cacciola (fernando.cacciola_at_[hidden])
Date: 2008-02-07 07:40:50

linux_at_[hidden] wrote:
> Does boost have a float-to-integer conversion?
There is Boost.NumericConversion

which provides:


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 =


Fernando Cacciola

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at