|
FAST Protocol
< Previous Next >
Re: Representing a double as a Fast scaled decimal
Dimitry London / Morgan Stanley <> 8 Oct 2008 9:07PM ETThanks, Daniel.
My first instinct was to use frexp() for double->decimal and ldexp() from decimal to double. When I ran some initial benchmarks today I did not notice any big overhead.
fxrexp() returns an integer exponent and normalized double mantissa (between 0.5 and 1.0). The real challenge is how to represent the results in a FAST wire representation - as the mantissa is still represented as a double/float rather then integer field. It is possible the send mantissa as a bit vector but then it will use at least 4/8 bytes) not counting the length. So, I don't really like this approach.
Dimitry
> Dimitry, I had posted a related thread a while back, see
> http://fixprotocol.org/discuss/read/eebb5ac9
>
> I think the optimal way to do this is to determine the amount of
> precision you want from the IEEE float or double, and extract the
> mantissa and exponent to create a scaled decimal. As you would expect,
> this needs to be optimized, and I am not sure the standard C lib methods
> are the way to go. Then comes the question of rounding vs. truncation.
>
> So, does someone want to submit a good algorithm for conversion ?
>
> /Daniel
Re: Representing a double as a Fast scaled decimal Dimitry London / Morgan Stanley 8 Oct 2008 9:07PM ET
|