How to use Decimal128 interfaces.
void example() {
EXPECT(d128{}.to_string() == "0E-6176");
EXPECT(d128{"0"}.to_string() == "0");
EXPECT(d128{"12"}.to_string() == "12");
EXPECT(d128{"-76"}.to_string() == "-76");
EXPECT(d128{"12.70"}.to_string() == "12.70");
EXPECT(d128{"+0.003"}.to_string() == "0.003");
EXPECT(d128{"017."}.to_string() == "17");
EXPECT(d128{".5"}.to_string() == "0.5");
EXPECT(d128{"4E+9"}.to_string() == "4E+9");
EXPECT(d128{"0.73e-7"}.to_string() == "7.3E-8");
EXPECT(d128{"Inf"}.to_string() == "Infinity");
EXPECT(d128{"-infinity"}.to_string() == "-Infinity");
EXPECT(d128{"NaN"}.to_string() == "NaN");
EXPECT(d128{"123"}.to_string() == "123");
EXPECT(d128{"-123"}.to_string() == "-123");
EXPECT(d128{"1.23E+3"}.to_string() == "1.23E+3");
EXPECT(d128{"1.23E+5"}.to_string() == "1.23E+5");
EXPECT(d128{"12.3"}.to_string() == "12.3");
EXPECT(d128{"0.00123"}.to_string() == "0.00123");
EXPECT(d128{"1.23E-8"}.to_string() == "1.23E-8");
EXPECT(d128{"-1.23E-10"}.to_string() == "-1.23E-10");
EXPECT(d128{"0"}.to_string() == "0");
EXPECT(d128{"0.00"}.to_string() == "0.00");
EXPECT(d128{"0E+2"}.to_string() == "0E+2");
EXPECT(d128{"-0"}.to_string() == "-0");
EXPECT(d128{"0.000005"}.to_string() == "0.000005");
EXPECT(d128{"0.0000050"}.to_string() == "0.0000050");
EXPECT(d128{"5E-7"}.to_string() == "5E-7");
EXPECT(d128{"Infinity"}.to_string() == "Infinity");
EXPECT(d128{"-Infinity"}.to_string() == "-Infinity");
EXPECT(d128{"NaN"}.to_string() == "NaN");
EXPECT(d128{"1.23E+3"}.to_string() == "1.23E+3");
EXPECT(d128{"123E+3"}.to_string() == "1.23E+5");
EXPECT(d128{"12.3E-9"}.to_string() == "1.23E-8");
EXPECT(d128{"-123E-12"}.to_string() == "-1.23E-10");
EXPECT(d128{"700E-9"}.to_string() == "7.00E-7");
EXPECT(d128{"70"}.to_string() == "70");
EXPECT(d128{"0.00E+3"}.to_string() == "0E+1");
EXPECT(d128{"0"}.to_string() == "0");
EXPECT(d128{"0.00"}.to_string() == "0.00");
EXPECT(d128{"123"}.to_string() == "123");
EXPECT(d128{"-123"}.to_string() == "-123");
EXPECT(d128{"1.23E3"}.to_string() == "1.23E+3");
EXPECT(d128{"1.23E+3"}.to_string() == "1.23E+3");
EXPECT(d128{"12.3E+7"}.to_string() == "1.23E+8");
EXPECT(d128{"12.0"}.to_string() == "12.0");
EXPECT(d128{"12.3"}.to_string() == "12.3");
EXPECT(d128{"0.00123"}.to_string() == "0.00123");
EXPECT(d128{"-1.23E-12"}.to_string() == "-1.23E-12");
EXPECT(d128{"1234.5E-4"}.to_string() == "0.12345");
EXPECT(d128{"-0"}.to_string() == "-0");
EXPECT(d128{"-0.00"}.to_string() == "-0.00");
EXPECT(d128{"0E+7"}.to_string() == "0E+7");
EXPECT(d128{"-0E-7"}.to_string() == "-0E-7");
EXPECT(d128{"inf"}.to_string() == "Infinity");
EXPECT(d128{"+inFiniTy"}.to_string() == "Infinity");
EXPECT(d128{"-Infinity"}.to_string() == "-Infinity");
EXPECT(d128{"NaN"}.to_string() == "NaN");
EXPECT(d128{"-NAN"}.to_string() == "NaN");
}
void example() {
EXPECT((d128{0u, 0u}) == d128{});
EXPECT((d128{0x3040000000000000, 0x0000000000000000}) == d128{"0"});
EXPECT((d128{0xb040000000000000, 0x0000000000000000}) == d128{"-0"});
EXPECT((d128{0x3040000000000000, 0x0000000000000000}) == d128{"00E0"});
EXPECT((d128{0x303e000000000000, 0x0000000000000000}) == d128{"0.0E0"});
EXPECT((d128{0x3040000000000000, 0x000000000000007b}) == d128{"123"});
EXPECT((d128{0xb040000000000000, 0x000000000000007b}) == d128{"-123"});
EXPECT((d128{0x3042000000000000, 0x000000000000007b}) == d128{"1.23E3"});
EXPECT((d128{0xb042000000000000, 0x000000000000007b}) == d128{"-1.23E3"});
EXPECT((d128{0x303e000000000000, 0x000000000000007b}) == d128{"12.3"});
EXPECT((d128{0xb03e000000000000, 0x000000000000007b}) == d128{"-12.3"});
EXPECT((d128{0x7800000000000000, 0x0000000000000000}) == d128{"Infinity"});
EXPECT((d128{0xf800000000000000, 0x0000000000000000}) == d128{"-Infinity"});
EXPECT((d128{0x7c00000000000000, 0x0000000000000000}) == d128{"NaN"});
EXPECT((d128{0xfc00000000000000, 0x0000000000000000}).to_string() == "NaN");
EXPECT((d128{0x7e00000000000000, 0x0000000000000000}).to_string() == "NaN");
EXPECT((d128{0x7e00000000000000, 0x0000000000000000}).to_string() == "NaN");
}