Discussion Forums

Re: Representing a double as a Fast scaled decimal
Dimitry London / Morgan Stanley <>
8 Oct 2008 9:07PM ET

Thanks, 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


Representing a double as a Fast scaled decimal
Dimitry London / Morgan Stanley   8 Oct 2008 12:50PM ET
Re: Representing a double as a Fast scaled decimal
Anders Furuhed / Pantor Engineering   8 Oct 2008 2:13PM ET
Re: Representing a double as a Fast scaled decimal
Dimitry London / Morgan Stanley   8 Oct 2008 3:06PM ET
Re: Representing a double as a Fast scaled decimal
Rolf Andersson / Pantor Engineering   8 Oct 2008 3:22PM ET
Re: Representing a double as a Fast scaled decimal
Dimitry London / Morgan Stanley   8 Oct 2008 3:47PM ET
Re: Representing a double as a Fast scaled decimal
Rolf Andersson / Pantor Engineering   8 Oct 2008 3:56PM ET
Re: Representing a double as a Fast scaled decimal
Dimitry London / Morgan Stanley   8 Oct 2008 4:04PM ET
Re: Representing a double as a Fast scaled decimal
Daniel May / SpryWare, LLC   8 Oct 2008 5:27PM ET
Re: Representing a double as a Fast scaled decimal
Dimitry London / Morgan Stanley   8 Oct 2008 9:07PM ET
Re: Representing a double as a Fast scaled decimal
Walter Mascarenhas / GeoCAD   8 Oct 2008 9:58PM ET
Re: Representing a double as a Fast scaled decimal
Daniel May / SpryWare, LLC   9 Oct 2008 9:47AM ET
Re: Representing a double as a Fast scaled decimal
Daniel May / SpryWare, LLC   9 Oct 2008 10:48AM ET
Re: Representing a double as a Fast scaled decimal
Walter Mascarenhas / GeoCAD   9 Oct 2008 11:45AM ET
Re: Representing a double as a Fast scaled decimal
Dimitry London / Morgan Stanley   9 Oct 2008 11:16PM ET
Re: Representing a double as a Fast scaled decimal
Walter Mascarenhas / GeoCAD   10 Oct 2008 7:30AM ET
Re: Representing a double as a Fast scaled decimal
Dimitry London / Morgan Stanley   9 Oct 2008 11:04PM ET