Page MenuHomePhabricator

[libc] add basic strtold implementation

Authored by michaelrj on Nov 11 2021, 1:19 PM.



Due to the differences between the types of long double, this function
is effectively three functions in one. This patch adds basic support for
the types of long double, although it's just using the fast path and the
fallback for the moment. I still need to implement a version of
Eisel-Lemire for performance, but the existing algorithms should be

Diff Detail

Event Timeline

michaelrj created this revision.Nov 11 2021, 1:19 PM
michaelrj requested review of this revision.Nov 11 2021, 1:19 PM
lntue accepted this revision.Nov 11 2021, 3:46 PM
lntue added inline comments.

Will the literal constant 1e23L work correctly for this?


You should add the suffix -L for the constant just in case the literal is converted to double before long double.


Check if the literal 1e23L, ... work properly.


Add suffix -L for the literal.

This revision is now accepted and ready to land.Nov 11 2021, 3:46 PM
michaelrj updated this revision to Diff 386682.Nov 11 2021, 4:32 PM
michaelrj marked 4 inline comments as done.

fix constants to properly use long doubles

sivachandra accepted this revision.Nov 12 2021, 4:54 PM
sivachandra added inline comments.

User reference arguments. Also, the name of this function should probably be setImplicitBit so that it is easy to explain/understand the NOP nature for IEEE-754 encodings.


May be I am missing something but I don't seem to find tests with different 64-bit, 80-bit and 128-bit errno. If they are missing, can we add them?

michaelrj updated this revision to Diff 387437.Nov 15 2021, 4:26 PM
michaelrj marked 2 inline comments as done.

fix inf rounding error and add a few tests. I'm planning on adding more, but I have other priority projects right now.

michaelrj added inline comments.Nov 16 2021, 11:34 AM

I've added tests with different errno behavior for the different sizes.

lntue accepted this revision.Nov 16 2021, 4:48 PM
michaelrj updated this revision to Diff 392509.Dec 7 2021, 1:03 PM

rebase for new formatting changes

michaelrj updated this revision to Diff 393614.Dec 10 2021, 3:45 PM

add a last round of tests before landing

This revision was automatically updated to reflect the committed changes.