[PATCH] D34518: [ADT] Add llvm::to_float

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 23 04:59:30 PDT 2017


Yea, it's fine as is, lgtm
On Fri, Jun 23, 2017 at 3:34 AM Pavel Labath via Phabricator <
reviews at reviews.llvm.org> wrote:

> labath added a comment.
>
> In https://reviews.llvm.org/D34518#788213, @efriedma wrote:
>
> > > it looks like it doesn't easily support long double
> >
> > APFloat::convertFromString works for every floating-point type supported
> by APFloat; clang uses it to parse floating-point literals.  There isn't
> any convenient way to convert an APFloat to a long double, but that's
> mostly because there hasn't been any demand for it; the format of long
> double is platform-dependent.
>
>
> I don't actually need long double support right now -- I just added it
> because it was easy.
>
> So the lack of long double would not be a show-stopper for using an
> APFloat-based solution. However, the convertFromString seems to assume that
> the input string has already been checked for correctness, as it is full of
> asserts. This means it's impossible to use it as a drop in replacement for
> the "parse me this string I got from the user" type of functionality, which
> is what the existing users of strtod do, and what I intended to use it for.
> That could of course be fixed, but given that we don't need the fancy
> features of APFloat here, and strtod is readily available everywhere, I am
> not sure if it's really worth it.
>
>
> https://reviews.llvm.org/D34518
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170623/8b90d0ca/attachment.html>


More information about the llvm-commits mailing list