[cfe-dev] precise double rewrite patch

Eli Friedman eli.friedman at gmail.com
Fri Sep 30 11:06:24 PDT 2011


On Fri, Sep 30, 2011 at 2:17 AM, Olaf Krzikalla
<Olaf.Krzikalla at tu-dresden.de> wrote:
> Hi @clang,
>
> the attached patch increases the precision of the FloatingLiteral rewrite
> significantly. With the patch sometimes the output is no longer "pretty".
> However it is always precise. Before the change I had serious trouble with
> rounding errors.
> I hope the proposed approach is considered better than the old one. Of
> course it might be possible to make it sometimes much prettier while not
> loosing too much precision but I'm not sure how exactly (what is the
> definition of "loosing too much precision") and whether it is worth the
> effort.

Your patch prints way too many digits: the second argument of toString
is digits, and semanticsPrecision is in bits.  Does Val.toString(Str)
(using the default value for the number of digits to print) not do the
right thing?

Also, you can simplify the code a bit by using SmallString instead of
SmallVector.

-Eli



More information about the cfe-dev mailing list