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