float CT stringification

Fawzi Mohamed fmohamed at mac.com
Thu Jun 5 06:10:21 PDT 2008

On 2008-06-05 15:08:47 +0200, Fawzi Mohamed <fmohamed at mac.com> said:

> On 2008-06-05 14:45:49 +0200, bearophile <bearophileHUGS at lycos.com> said:
>> Fawzi Mohamed:
>>> I don't think that you really gain something by making the
>>> weight value compiletime, just the sparsity structure (number of
>>> variables) makes you gain something...
>> Right, the gain comes only from not doing the multiplication where the 
>> coefficient is 1, and not doing anything where it's zero.
>> Still, I'd like to have a CT toString(float).
>> Bye,
>> bearophile
> maybe, if nobody answers, you have to roll your own, and then you can 
> contribute it back...
> with
> real frexp (real value, out int exp);
> and then a bit per bit extraction of value using scalbn or ldexp, 
> checking >=0, removing the bit and iterating... e even simpler multipy 
> with 2**n_mantissa and cast to integer, and you should be able to do 
> convert a float in two integers that you can then write out.
> one should be careful and check that with denormalized numbers it still works
> http://www.dsource.org/projects/tango/docs/current/tango.math.IEEE.html

well at least the mantissa should be a long...

More information about the Digitalmars-d-learn mailing list