diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2013-08-28 05:23:51 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2013-08-28 05:23:51 +0000 |
commit | 14cede282958c4f6162239b58ff7395223435cfb (patch) | |
tree | b934dd88c2b0794dfdf842efc8974cca0334fdf2 /llvm/unittests/ADT/APFloatTest.cpp | |
parent | 108c46a7bf92342aa1661c36e4b85cd2b24d7f4e (diff) | |
download | llvm-14cede282958c4f6162239b58ff7395223435cfb.zip llvm-14cede282958c4f6162239b58ff7395223435cfb.tar.gz llvm-14cede282958c4f6162239b58ff7395223435cfb.tar.bz2 |
Change default # of digits for APFloat::toString
The previous default was almost, but not quite enough digits to
represent a floating-point value in a manner which preserves the
representation when it's read back in. The larger default is much
less confusing.
I spent some time looking into printing exactly the right number of
digits if a precision isn't specified, but it's kind of complicated,
and I'm not really sure I understand what APFloat::toString is supposed
to output for FormatPrecision != 0 (or maybe the current API specification
is just silly, not sure which). I have a WIP patch if anyone is interested.
llvm-svn: 189442
Diffstat (limited to 'llvm/unittests/ADT/APFloatTest.cpp')
-rw-r--r-- | llvm/unittests/ADT/APFloatTest.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/unittests/ADT/APFloatTest.cpp b/llvm/unittests/ADT/APFloatTest.cpp index 3b69de2..e57c8d4 100644 --- a/llvm/unittests/ADT/APFloatTest.cpp +++ b/llvm/unittests/ADT/APFloatTest.cpp @@ -866,10 +866,11 @@ TEST(APFloatTest, toString) { ASSERT_EQ("0.0101", convertToString(1.01E-2, 5, 2)); ASSERT_EQ("0.0101", convertToString(1.01E-2, 4, 2)); ASSERT_EQ("1.01E-2", convertToString(1.01E-2, 5, 1)); - ASSERT_EQ("0.7853981633974483", convertToString(0.78539816339744830961, 0, 3)); - ASSERT_EQ("4.940656458412465E-324", convertToString(4.9406564584124654e-324, 0, 3)); - ASSERT_EQ("873.1834", convertToString(873.1834, 0, 1)); - ASSERT_EQ("8.731834E+2", convertToString(873.1834, 0, 0)); + ASSERT_EQ("0.78539816339744828", convertToString(0.78539816339744830961, 0, 3)); + ASSERT_EQ("4.9406564584124654E-324", convertToString(4.9406564584124654e-324, 0, 3)); + ASSERT_EQ("873.18340000000001", convertToString(873.1834, 0, 1)); + ASSERT_EQ("8.7318340000000001E+2", convertToString(873.1834, 0, 0)); + ASSERT_EQ("1.7976931348623157E+308", convertToString(1.7976931348623157E+308, 0, 0)); } TEST(APFloatTest, toInteger) { |